I m trying to connect my android app to a Tcp iot server,first i connect to the tcp server using wifi then try socket connect but it is showing same error of connection timed out.
print(r);
}).catchError((e) {
print(e);
});
wifi connects without any error.
Socket.connect("192.168.5.10", 5800).then((socket) {
print('Connected to: '
'${socket.remoteAddress.address}:${socket.remotePort}');
socket.destroy();
});
Here it shows Unhandled Exception: SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.5.10, port = 49590
I used http package in flutter. And got the same error as yours. My solution is 'I used ngrok to expose my localhost' then I change my url to the url that ngrok forward. -Note: Use ngrok to test the api only. And when we host the to the server, there will not be any problems related to response time so you can use your server ip.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With