How to debug SocketTimeoutException?

ぐ巨炮叔叔 提交于 2019-12-24 02:33:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!