Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix 'SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.5.10, port = 49590' error in flutter

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

like image 616
Amarjot Singh Avatar asked Jul 08 '19 07:07

Amarjot Singh


1 Answers

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.

like image 137
Sambat Avatar answered Oct 07 '22 03:10

Sambat