How to debug SocketTimeoutException?
We are getting a java.net.SocketTimeoutException
on server B when client A connects to server B. No idea why. The c开发者_运维问答lient is sending data to the server and the server then throws this exception. How would one troubleshoot this issue?
Note currently this has happened only once. Not sure if this is reproduceable. Attempting to setup the test again..
I had same problems, when my users used 3G or 2G network. It means, that you send request to server, and can't estabilish connection, because of weak internet signal. You can increase timeouts on your connection
URLConnection connection;
int timeout = 30 * 1000;
connection.setConnectTimeout(timeout);
connection.setReadTimeout(timeout);
But if you have weaaak weeeaaaak internet connection
, timeouts does not help you.
I'm just created 1 testFunction in WebService
(or you can use one of yours) for testing connection
with server
before calling another required functions, and if I get SockectTimeoutException
calling this function - just report to user notification "Weak internet connection!".
No data arrived at the receiver within the timeout period. That's all it means. Debugging it means finding out why the data you think was sent wasn't sent. A missing flush() for example.
精彩评论