Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Network request failing ONLY in mobile network. On WIFI it does work as expected. #1752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vidriloco opened this issue Apr 15, 2025 · 2 comments
Labels
needs-info Additional information needed from the issue author package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@vidriloco
Copy link

vidriloco commented Apr 15, 2025

Hello folks,

I have two Flutter apps running for a while already and I just noticed that the two of them are failing to complete a simple GET request but only when done using the mobile network. If I execute the request using the WIFI network, then there is no problem.

Here's the error I am getting:

flutter: Error fetching POIs after 3 attempts: ClientException with SocketException: Connection failed (OS Error: Network is unreachable, errno = 51), address = 0.78.103.114, port = 8000, uri=http://0.78.103.114:8000/pois/ flutter: Error: ClientException with SocketException: Connection failed (OS Error: Network is unreachable, errno = 51), address = 0.78.103.114, port = 8000, uri=http://0.78.103.114:8000/pois/

Below is the code that I am using to launch the request in one of those apps:

final response = await http.get(Uri.parse("http://$backendIPAddress:$backendPort/pois/")) .timeout(const Duration(seconds: 10));

Furthermore, I tested with a dummy endpoint serving a JSON and this one works correctly:

final testResponse = await http.get(Uri.parse('https://jsonplaceholder.typicode.com/todos/1')); print('Test API Response: ${testResponse.body}');

My device is running on iOS 18.1, just updated it to 18.4 to see if it made a difference, but none.

Here's my pubspec.yaml contents:

  sdk: ">=2.17.1 <3.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  mapbox_gl: ^0.16.0
  rxdart: ^0.27.7
  latlong2: ^0.8.1
  lottie: ^1.4.2
  http: ^1.2.2
  timeago: ^3.2.2
  shared_preferences: ^2.2.2
  url_launcher: ^6.0.9
  mixpanel_flutter: ^2.0.0
  geolocator: ^11.1.0
  permission_handler: ^11.0.1
  flutter_html: ^3.0.0-beta.2
  intl: ^0.19.0
  photo_view: ^0.14.0
  flutter_staggered_grid_view: ^0.6.2
  flutter_cache_manager: ^3.4.1
  dots_indicator: ^2.1.1
  flutter_localizations:
    sdk: flutter
  json_annotation: ^4.8.1
  connectivity_plus: ^5.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0
  json_serializable: ^6.7.1
  build_runner: ^2.4.7

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

dependency_overrides:
  win32: ^5.5.4
@vidriloco vidriloco added package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Apr 15, 2025
@itcozum
Copy link

itcozum commented Apr 23, 2025

I'm having this very same issue.
can reach my API during development, but after release can't reach my API's.

@brianquinlan
Copy link
Collaborator

My reading of RFC-1700 is that {0, <Host-number>} is only routable on the local network and your destination IP is 0.78.103.114.

Is that the IP address that you meant to access from a mobile network?

@brianquinlan brianquinlan added the needs-info Additional information needed from the issue author label May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info Additional information needed from the issue author package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants