Network request failing ONLY in mobile network. On WIFI it does work as expected. #1752
Labels
needs-info
Additional information needed from the issue author
package:http
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
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:
The text was updated successfully, but these errors were encountered: