dart-lang / http

A composable API for making HTTP requests in Dart.
https://pub.dev/packages/http
BSD 3-Clause "New" or "Revised" License
1.03k stars 358 forks source link

while Making any Http Request on real device to server by using IP and port getting SocketException and wrong port number in logs #516

Closed zubairshahzadarain closed 3 years ago

zubairshahzadarain commented 3 years ago

i have created web service on my personal server in same network .. this web server is working fine and available on same network . i have test with postman from android device . and i also create one native andorid application using java .its working fine in native android .

but in a flutter, i have test three libraries getting below results please help to fix this issue

static String baseurl ="http://10.183.121.43:5000/";

try { Response response = await Dio().get(constant.baseurl+"hello/"); print(response); } catch (e) { print(e); } try { await RawSocket.connect("10.183.121.43", 5000); } catch (e) { print(e); } var client = new http.Client(); client.post(myurl,headers : { "Content-Type": "application/x-www-form-urlencoded" }, body: { "username": useridcontroler.text, "password": passwordController.text })

Error : SocketException: OS Error: Connection timed out, errno = 110, address = 10.183.121.43, port = 55705

http: 0.12.2 logs: git: url: https://github.com/pq/logs.git ref: master rflutter_alert: 1.0.3 shared_preferences: 0.5.12+4 image_picker: 0.6.7+17 dio: 3.0.10 progress_dialog: 1.2.4 location: 3.0.0

Note : same thing when i am trying using ngrok tool and passing ngrok address its working perfectly in flutter .. but with server ip url its not working

zubairshahzadarain commented 3 years ago

please do poc by using any server ip .. just use IP and port in url not domain name .. i have tested with two server all plugins giving me same error .. i have test 3 4 libraries .. and with socket

natebosch commented 3 years ago

From the report it looks like the exception is not coming from this package.

i have test 3 4 libraries .. and with socket

If 3-4 libraries exhibit the same behavior the bug is very unlikely to be caused by those libraries. This is more likely an issue with your environment (like ensuring you have internet permissions and can make http as opposed to https requests.

The incorrect port in the message is related to https://github.com/dart-lang/sdk/issues/12693

The fact that a SocketException is raised is likely due to permissions or the environment - the flutter team is most likely the resource that can help with that.

If you can consistently reproduce a problem using dart:io and believe the issue is not the environment you can file an issue with a minimal reproduction on the Dart SDK repo. https://github.com/dart-lang/sdk/issues

OlegBezr commented 3 years ago

@zubairshahzad, did you make any progress on this problem?