开发者

How to debug SocketTimeoutException?

开发者 https://www.devze.com 2023-03-19 22:21 出处:网络
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 exce

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消