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 Litty <pr...@gmail.com> on 2011/10/10 14:09:47 UTC
ConnectTimeoutException after 5 to 6 hrs
Hi,
I am using httpclient 4.1.2. If I do a connect to a particular IP and keep
the client program running for more than 5 to 6 hr, it starts giving:
org.apache.http.conn.ConnectTimeoutException: Connect to XXXXX timed out
at
org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:377)
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at
org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
If I connect to a different IP, it will succeed. The problem goes away once
I restart my client program.
Server is a tomcat 6. Both client and server are running on JRE 5.
Please help me with this. Do let me know if you need any extra info.
Regards,
Litty
--
View this message in context: http://old.nabble.com/ConnectTimeoutException-after-5-to-6-hrs-tp32623247p32623247.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: ConnectTimeoutException after 5 to 6 hrs
Posted by Litty Preeth <pr...@gmail.com>.
Hi,
I think EntityUtils.consume(entity); has did the trick. Now the client has
been running for past 2 days and the connection timeout is not happening.
Thanks,
Litty Preeth
On Wed, Oct 26, 2011 at 1:07 AM, Vasile Alin <al...@gmail.com>wrote:
> >> Someone suggested that I these issue comes if the response is not fully
> >> emptied. Also if I enable the wire and header debug for httpclient, I am
> >> not
> >> getting this issue. So may be the root cause is because the response is
> not
> >> fully drained.
> >>
>
> Could be possible. When the issue appears, did you checked how many
> sockets do you have on you machine (using netstat) for that particular
> destination and their state?
>
> Alin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Re: ConnectTimeoutException after 5 to 6 hrs
Posted by Vasile Alin <al...@gmail.com>.
>> Someone suggested that I these issue comes if the response is not fully
>> emptied. Also if I enable the wire and header debug for httpclient, I am
>> not
>> getting this issue. So may be the root cause is because the response is not
>> fully drained.
>>
Could be possible. When the issue appears, did you checked how many
sockets do you have on you machine (using netstat) for that particular
destination and their state?
Alin
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: ConnectTimeoutException after 5 to 6 hrs
Posted by Jordi Domingo Borràs <jo...@gmail.com>.
Hi Litty,
You can do:
EntityUtils.consume(entity);
Regards,
Jordi
On Tue, Oct 25, 2011 at 11:07, Litty Preeth <pr...@gmail.com> wrote:
> I posted the same issue on stackoverflow:
>
> http://stackoverflow.com/questions/7723558/apache-httpclient-giving-connection-timeout-after-5-ot-6-hrs
>
> Someone suggested that I these issue comes if the response is not fully
> emptied. Also if I enable the wire and header debug for httpclient, I am
> not
> getting this issue. So may be the root cause is because the response is not
> fully drained. I tried the following for every request:
>
> int statusCode = res.getStatusLine().getStatusCode();
> String reasonPhrase = res.getStatusLine().getReasonPhrase();
> Header[] headers = res.getAllHeaders();
> HashMap<String, String> headerMap = new HashMap<String, String>();
> if (headers != null) {
> for (Header header : headers) {
> if (header != null) {
> headerMap.put(header.getName(), header.getValue());
> }
> }
> }
> HttpEntity resEntity = res.getEntity();
> if (resEntity != null && resEntity.getContentLength() > 0) {
> ByteArrayOutputStream os = new ByteArrayOutputStream();
> resEntity.writeTo(os);
> resStr = os.toString();
> }
>
> But I am still getting the issue if I don't turn on debug logging. So can
> anybody suggest how to empty a response?
>
> Regards,
> Litty Preeth
>
> On Thu, Oct 20, 2011 at 1:47 AM, Vasile Alin <alinachegalati@gmail.com
> >wrote:
>
> > On 18 October 2011 08:05, Litty <pr...@gmail.com> wrote:
> >
> > > I am able to connect to the same URL from the same machine using a
> > browser.
> > > So I don't think the issue is with web server.
> > >
> >
> > This doesn't prove that there are no issues with the web server.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >
>
Re: ConnectTimeoutException after 5 to 6 hrs
Posted by Litty Preeth <pr...@gmail.com>.
I posted the same issue on stackoverflow:
http://stackoverflow.com/questions/7723558/apache-httpclient-giving-connection-timeout-after-5-ot-6-hrs
Someone suggested that I these issue comes if the response is not fully
emptied. Also if I enable the wire and header debug for httpclient, I am not
getting this issue. So may be the root cause is because the response is not
fully drained. I tried the following for every request:
int statusCode = res.getStatusLine().getStatusCode();
String reasonPhrase = res.getStatusLine().getReasonPhrase();
Header[] headers = res.getAllHeaders();
HashMap<String, String> headerMap = new HashMap<String, String>();
if (headers != null) {
for (Header header : headers) {
if (header != null) {
headerMap.put(header.getName(), header.getValue());
}
}
}
HttpEntity resEntity = res.getEntity();
if (resEntity != null && resEntity.getContentLength() > 0) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
resEntity.writeTo(os);
resStr = os.toString();
}
But I am still getting the issue if I don't turn on debug logging. So can
anybody suggest how to empty a response?
Regards,
Litty Preeth
On Thu, Oct 20, 2011 at 1:47 AM, Vasile Alin <al...@gmail.com>wrote:
> On 18 October 2011 08:05, Litty <pr...@gmail.com> wrote:
>
> > I am able to connect to the same URL from the same machine using a
> browser.
> > So I don't think the issue is with web server.
> >
>
> This doesn't prove that there are no issues with the web server.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Re: ConnectTimeoutException after 5 to 6 hrs
Posted by Vasile Alin <al...@gmail.com>.
On 18 October 2011 08:05, Litty <pr...@gmail.com> wrote:
> I am able to connect to the same URL from the same machine using a browser.
> So I don't think the issue is with web server.
>
This doesn't prove that there are no issues with the web server.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: ConnectTimeoutException after 5 to 6 hrs
Posted by Litty <pr...@gmail.com>.
Hi,
I am able to connect to the same URL from the same machine using a browser.
So I don't think the issue is with web server.
Regards,
Litty Preeth
olegk wrote:
>
> On Wed, 2011-10-12 at 14:10 +0300, Vasile Alin wrote:
>> Are you sure this is not caused by your web server?
>>
>
> The server is clearly unable to handle additional connections after a
> while, so this does seem to suggest a server side issue.
>
> Oleg
>
>
>> On 11 October 2011 11:24, Litty <pr...@gmail.com> wrote:
>> >
>> > Hi,
>> >
>> > Posting some extra info.
>> >
>> > I have set connection timeout = 5000 and socket timeout = 60000. I am
>> using
>> > DefaultHttpClient with SingleClientConnManager.
>> >
>> > If anyone can point to the direction in which I can debug it, that
>> itself
>> > would be really helpful.
>> >
>> > Regards,
>> > Litty
>> >
>> >
>> > Litty wrote:
>> >>
>> >> Hi,
>> >>
>> >> I am using httpclient 4.1.2. If I do a connect to a particular IP and
>> keep
>> >> the client program running for more than 5 to 6 hr, it starts giving:
>> >> org.apache.http.conn.ConnectTimeoutException: Connect to XXXXX timed
>> out
>> >> at
>> >>
>> org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:377)
>> >> at
>> >>
>> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
>> >> at
>> >>
>> org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
>> >> at
>> >>
>> org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
>> >> at
>> >>
>> org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
>> >> at
>> >>
>> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
>> >> at
>> >>
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>> >> at
>> >>
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>> >> at
>> >>
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>> >>
>> >> If I connect to a different IP, it will succeed. The problem goes away
>> >> once I restart my client program.
>> >>
>> >> Server is a tomcat 6. Both client and server are running on JRE 5.
>> >>
>> >> Please help me with this. Do let me know if you need any extra info.
>> >>
>> >> Regards,
>> >> Litty
>> >>
>> >
>> > --
>> > View this message in context:
>> http://old.nabble.com/ConnectTimeoutException-after-5-to-6-hrs-tp32623247p32629119.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
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
>
--
View this message in context: http://old.nabble.com/ConnectTimeoutException-after-5-to-6-hrs-tp32623247p32672241.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: ConnectTimeoutException after 5 to 6 hrs
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2011-10-12 at 14:10 +0300, Vasile Alin wrote:
> Are you sure this is not caused by your web server?
>
The server is clearly unable to handle additional connections after a
while, so this does seem to suggest a server side issue.
Oleg
> On 11 October 2011 11:24, Litty <pr...@gmail.com> wrote:
> >
> > Hi,
> >
> > Posting some extra info.
> >
> > I have set connection timeout = 5000 and socket timeout = 60000. I am using
> > DefaultHttpClient with SingleClientConnManager.
> >
> > If anyone can point to the direction in which I can debug it, that itself
> > would be really helpful.
> >
> > Regards,
> > Litty
> >
> >
> > Litty wrote:
> >>
> >> Hi,
> >>
> >> I am using httpclient 4.1.2. If I do a connect to a particular IP and keep
> >> the client program running for more than 5 to 6 hr, it starts giving:
> >> org.apache.http.conn.ConnectTimeoutException: Connect to XXXXX timed out
> >> at
> >> org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:377)
> >> at
> >> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
> >> at
> >> org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
> >> at
> >> org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
> >> at
> >> org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
> >> at
> >> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
> >> at
> >> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
> >> at
> >> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
> >> at
> >> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
> >>
> >> If I connect to a different IP, it will succeed. The problem goes away
> >> once I restart my client program.
> >>
> >> Server is a tomcat 6. Both client and server are running on JRE 5.
> >>
> >> Please help me with this. Do let me know if you need any extra info.
> >>
> >> Regards,
> >> Litty
> >>
> >
> > --
> > View this message in context: http://old.nabble.com/ConnectTimeoutException-after-5-to-6-hrs-tp32623247p32629119.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
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: ConnectTimeoutException after 5 to 6 hrs
Posted by Vasile Alin <al...@gmail.com>.
Are you sure this is not caused by your web server?
On 11 October 2011 11:24, Litty <pr...@gmail.com> wrote:
>
> Hi,
>
> Posting some extra info.
>
> I have set connection timeout = 5000 and socket timeout = 60000. I am using
> DefaultHttpClient with SingleClientConnManager.
>
> If anyone can point to the direction in which I can debug it, that itself
> would be really helpful.
>
> Regards,
> Litty
>
>
> Litty wrote:
>>
>> Hi,
>>
>> I am using httpclient 4.1.2. If I do a connect to a particular IP and keep
>> the client program running for more than 5 to 6 hr, it starts giving:
>> org.apache.http.conn.ConnectTimeoutException: Connect to XXXXX timed out
>> at
>> org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:377)
>> at
>> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
>> at
>> org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
>> at
>> org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
>> at
>> org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
>> at
>> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
>> at
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>> at
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>> at
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>>
>> If I connect to a different IP, it will succeed. The problem goes away
>> once I restart my client program.
>>
>> Server is a tomcat 6. Both client and server are running on JRE 5.
>>
>> Please help me with this. Do let me know if you need any extra info.
>>
>> Regards,
>> Litty
>>
>
> --
> View this message in context: http://old.nabble.com/ConnectTimeoutException-after-5-to-6-hrs-tp32623247p32629119.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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: ConnectTimeoutException after 5 to 6 hrs
Posted by Litty <pr...@gmail.com>.
Hi,
Posting some extra info.
I have set connection timeout = 5000 and socket timeout = 60000. I am using
DefaultHttpClient with SingleClientConnManager.
If anyone can point to the direction in which I can debug it, that itself
would be really helpful.
Regards,
Litty
Litty wrote:
>
> Hi,
>
> I am using httpclient 4.1.2. If I do a connect to a particular IP and keep
> the client program running for more than 5 to 6 hr, it starts giving:
> org.apache.http.conn.ConnectTimeoutException: Connect to XXXXX timed out
> at
> org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:377)
> at
> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
> at
> org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
> at
> org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
> at
> org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
> at
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
> at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
> at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
> at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>
> If I connect to a different IP, it will succeed. The problem goes away
> once I restart my client program.
>
> Server is a tomcat 6. Both client and server are running on JRE 5.
>
> Please help me with this. Do let me know if you need any extra info.
>
> Regards,
> Litty
>
--
View this message in context: http://old.nabble.com/ConnectTimeoutException-after-5-to-6-hrs-tp32623247p32629119.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