问题
We are getting a java.net.SocketTimeoutException
on server B when client A connects to server B. No idea why. The client 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..
回答1:
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.
回答2:
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!".
来源:https://stackoverflow.com/questions/6650129/how-to-debug-sockettimeoutexception