13

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

0

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.