MyWifiMesh icon indicating copy to clipboard operation
MyWifiMesh copied to clipboard

SocketTimeoutException: failed to connect to IP address and port

Open yangster23 opened this issue 8 years ago • 4 comments

Hello,

I've been attempting to implement and test this code, but after retrieving the IP address of the connection and starting the client socket, the socket always times out. I believe its because there is more than one of the same IP address, but I may be wrong and am not sure how to fix this problem. The error I receive is "Client: java.net.SocketTimeoutException: failed to connect to / 192.168.49.1 (port 38765 after 5000ms. isConnected failed: ETIMEDOUT (Connection timed out)"

What should happen I believe is that after the client socket connects to the other device's IP address and the access point is removed. There should be a message from the group owner and the client. I actually replicated this, by manually going to my Wifi connections and directly connecting to the other phone.

Note: this screenshot is of my Galaxy S6 Edge, which attempting to connect to a LG G4.

I would greatly appreciate the help!

Thank you!

Jonathan Yang

screenshot_20170108-131707

yangster23 avatar Jan 08 '17 18:01 yangster23

Or, I suspect that despite the application's attempt to remove the access point in step 6. The device is actually communicating with its own server, hence why the client socket will not connect. However, I am unsure how to solve the problem.

yangster23 avatar Jan 08 '17 18:01 yangster23

Hey yangster23 were you able to find out the reason behind this behavior? Please share if you have any fix for this!

harshvardhan avatar May 20 '17 21:05 harshvardhan

Sometimes the socket is work and sending the message that in message handler but otherwise always giving that exception. Any clue guys what the problems makes this behavior that causing throwing the exception, I hope Mr. @DrJukka have time for the solution thank you in advance.

Kholash avatar Jun 09 '17 16:06 Kholash

Hi kholash, yangster23 has rightly suspected that the client itself has not been able to purge the 192.168.49.1 address.

I solved it by not starting AP service for devices which were acting as client.

harshvardhan avatar Jun 09 '17 18:06 harshvardhan