My phone is connected to the same wireless network as my pc. I assume it’s some sort of network setting somewhere, no idea what though. Other devices on the same network connect and interact on the network fine.
But when I try to visit ip:19000 directly on Android emulator chrome it does return the json but it takes awhile and that explains the timeout. The client is just not waiting enough, is there a way to increase client timeout?
Btw I also tried creating new bare project from scratch and I can confirm it also loads prolly because there’s not much dependency that the json file is smaller and returns faster.
Oh this is funny, after running that bare project I switched to my actual project and run it again and now I don’t get a timeout and my app starts loading on Android emulator again.
It feels like a cache of sorts got reset that it started working again. Weird, but at least I’m good for now.
You can effectively handle it by define a connection timeout and later handle it by using a try-catch block. From the client side you can use the following method and set the timeout parameter:
clientSocket.connect(SocketAddress,timeout)
From the server side you can use the following method and set the timeout parameter:
serverSocket.setSoTimeout(timeout)
Also, if you are a programmer, you can surround the socket connection part of your code in a java try/catch/finally and handle the error in the catch. You might try connecting a second time, or try connecting to another possible socket, or simply exit the program cleanly.