java.net.SocketTimeoutException: Read timed out under Tomcat
Solution 1:
Server is trying to read data from the request, but its taking longer than the timeout value for the data to arrive from the client. Timeout here would typically be tomcat connector -> connectionTimeout attribute.
Correct.
Client has a read timeout set, and server is taking longer than that to respond.
No. That would cause a timeout at the client.
One of the threads i went through, said this can happen with high concurrency and if the keepalive is enabled.
That is obviously guesswork, and completely incorrect. It happens if and only if no data arrives within the timeout. Period. Load and keepalive and concurrency have nothing to do with it whatsoever.
It just means the client isn't sending. You don't need to worry about it. Browser clients come and go in all sorts of strange ways.
Solution 2:
Here are the basic instructions:-
- Locate the "server.xml" file in the "conf" folder beneath Tomcat's base directory (i.e.
%CATALINA_HOME%/conf/server.xml
). - Open the file in an editor and search for
<Connector
. - Locate the relevant connector that is timing out - this will typically be the HTTP connector, i.e. the one with
protocol="HTTP/1.1"
. - If a
connectionTimeout
value is set on the connector, it may need to be increased - e.g. from 20000 milliseconds (= 20 seconds) to 120000 milliseconds (= 2 minutes). If noconnectionTimeout
property value is set on the connector, the default is 60 seconds - if this is insufficient, the property may need to be added. - Restart Tomcat
Solution 3:
Connection.Response resp = Jsoup.connect(url) //
.timeout(20000) //
.method(Connection.Method.GET) //
.execute();
actually, the error occurs when you have slow internet so try to maximize the timeout time and then your code will definitely work as it works for me.