You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by tompra <ma...@tomasparal.cz> on 2009/10/15 18:16:29 UTC
HttpClient 4.0. SocketTimeoutException and RST signal problem
Hi,
I have problem with RST signal from instance of HttpClient that invokes a
SocketTimeoutException: Read Timeout.
In an attachement there is an image of network communication between my
client and server, where client invokes RST.
http://www.nabble.com/file/p25911599/SocketTimeoutException1.jpg
SocketTimeoutException1.jpg
My client makes a lot of correct requests but sometimes there is a problem
with RST. Sometimes comes many SocketTimeoutException in the same time and
than we haven't problem several next hours. Can the server be a reason of
this problem?
The exception is:
class java.net.SocketTimeoutException:
Read timed out
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:130)
org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:127)
org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:233)
org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98)
org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:210)
org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:271)
org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:227)
org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:229)
org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:292)
org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:126)
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:447)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
My code is:
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, 30000);
HttpConnectionParams.setSoTimeout(params, 30000);
HttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler(3,
true);
DefaultHttpClient httpClient = new DefaultHttpClient(params);
httpClient.setHttpRequestRetryHandler(retryHandler);
HttpGet httpGet = new HttpGet(URIUtil.encodeQuery(targetUrl));
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity == null) {
throw new ....
}
String content = EntityUtils.toString(entity);
Can you help me and show me the way? Thank you.
Best regards,
Tom
--
View this message in context: http://www.nabble.com/HttpClient-4.0.-SocketTimeoutException-and-RST-signal-problem-tp25911599p25911599.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: HttpClient 4.0. SocketTimeoutException and RST signal problem
Posted by Oleg Kalnichevski <ol...@apache.org>.
tompra wrote:
> Hi,
>
> I have problem with RST signal from instance of HttpClient that invokes a
> SocketTimeoutException: Read Timeout.
>
This is because HttpClient automatically closes connections that time
out on an I/O operation.
> In an attachement there is an image of network communication between my
> client and server, where client invokes RST.
>
> http://www.nabble.com/file/p25911599/SocketTimeoutException1.jpg
> SocketTimeoutException1.jpg
>
> My client makes a lot of correct requests but sometimes there is a problem
> with RST. Sometimes comes many SocketTimeoutException in the same time and
> than we haven't problem several next hours. Can the server be a reason of
> this problem?
Yes, absolutely. Most likely this is a server related issue.
>
> The exception is:
>
> class java.net.SocketTimeoutException:
> Read timed out
> java.net.SocketInputStream.socketRead0(Native Method)
> java.net.SocketInputStream.read(SocketInputStream.java:129)
> org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:130)
> org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:127)
> org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:233)
> org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98)
> org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:210)
> org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:271)
> org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:227)
> org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:229)
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:292)
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:126)
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:447)
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
>
> My code is:
>
> HttpParams params = new BasicHttpParams();
> HttpConnectionParams.setConnectionTimeout(params, 30000);
> HttpConnectionParams.setSoTimeout(params, 30000);
>
> HttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler(3,
> true);
>
> DefaultHttpClient httpClient = new DefaultHttpClient(params);
> httpClient.setHttpRequestRetryHandler(retryHandler);
>
> HttpGet httpGet = new HttpGet(URIUtil.encodeQuery(targetUrl));
>
> HttpResponse response = httpClient.execute(httpGet);
>
> HttpEntity entity = response.getEntity();
> if (entity == null) {
> throw new ....
> }
>
> String content = EntityUtils.toString(entity);
>
> Can you help me and show me the way? Thank you.
>
Maybe 30 second timeout is just too small. Try setting it to a greater
number (3 minutes, for instance).
Oleg
> Best regards,
>
> Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: HttpClient 4.0. SocketTimeoutException and RST signal problem
Posted by tompra <ma...@tomasparal.cz>.
Anyone?
Do you have any idea? Where I made a mistake?
Tom
tompra wrote:
>
> Hi,
>
> I have problem with RST signal from instance of HttpClient that invokes a
> SocketTimeoutException: Read Timeout.
>
>
--
View this message in context: http://www.nabble.com/HttpClient-4.0.-SocketTimeoutException-and-RST-signal-problem-tp25911599p25925311.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: HttpClient 4.0. SocketTimeoutException and RST signal problem
Posted by tompra <ma...@tomasparal.cz>.
Thank you for your help. I increse timeouts and connector is running fine
without problems.
Best Regards,
Tom
--
View this message in context: http://old.nabble.com/HttpClient-4.0.-SocketTimeoutException-and-RST-signal-problem-tp25911599p26432212.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org