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 Mohit Anchlia <mo...@gmail.com> on 2012/01/30 18:35:06 UTC
Re: Your thoughts on Readtimeout - releaseConnection
I am using 4.1.2 and I see that releaseConnection on specific
put/post/get/delete was removed since 3.1. Do I still have a need to
release connection?
On Sat, Jan 28, 2012 at 10:34 AM, Mohit Anchlia <mo...@gmail.com> wrote:
> I found that we are not calling releaseConnection and I think it's
> somehow related to that. But it still doesn't explain the below
> behaviour where B responded 10 secs before A timedout. Is this some
> kind of a race condition when releaseConnection is not called?
>
> On Fri, Jan 27, 2012 at 4:07 PM, Mohit Anchlia <mo...@gmail.com> wrote:
>> We are seeing a wierd behaviour and I am wondering if some kind of
>> session stickyness might be in play.
>>
>> We use HttpClient in Jboss to send post request from A -> B, then B ->
>> replies with 404 but after 15 secs (timeout on the request) we get
>> below timeout even though B -> replied to A in few millisecs. I can
>> see in B (apache) logs that response was sent in few ms. So don't
>> understand what is causing the timeout and why.
>>
>> java.net.SocketTimeoutException: Read timed out
>> at java.net.SocketInputStream.socketRead0(Native Method)
>> at java.net.SocketInputStream.read(SocketInputStream.java:129)
>> at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
>> at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Your thoughts on Readtimeout - releaseConnection
Posted by Mohit Anchlia <mo...@gmail.com>.
On Mon, Jan 30, 2012 at 5:46 PM, Karthik K <os...@gmail.com> wrote:
> On Mon, Jan 30, 2012 at 5:20 PM, Mohit Anchlia <mo...@gmail.com>wrote:
>
>> On Mon, Jan 30, 2012 at 2:07 PM, Karthik K <os...@gmail.com> wrote:
>> > We would still need to release the http connections and the resources for
>> > the http response.
>> >
>> > See the patch for HTTPCLIENT-1159 for details: ( 1) shutting down
>> > connection manager and 2) closing stream of http entity as part of
>> response
>> > ).
>>
>> Few follow up questions:
>>
>> 1) shutdown is required only when shutting down the app, correct? I
>> mean is shutdown is required after every http request?
>>
>
> True. shutdown of a (http)client is a 1-time effort ( depending on the
> connection manager, assuming that it is thread-safe).
>
>
>
>> 2) I am using EntityUtils.toByteArray(entity), So how do I close the
>> stream in this case?
>>
>
> entity has an InputStream in it, and you can 'consumeContent' off the same.
>
>
I looked at the code of EntityUtils and it looks like it is already
closing the inputStream. So do I still need to consume it after
calling EntityUtils.toByteArray(entity)?
I am little confused here. Looks like I don't need to call consume.
>
>>
>> >
>> > While the patch comes in 4.2 in the future, we need to do the equivalent
>> of
>> > the same when releasing connections though, for httpclient < 4.2 .
>> >
>> > --
>> > Karthik.
>> >
>> >
>> > On Mon, Jan 30, 2012 at 9:35 AM, Mohit Anchlia <mohitanchlia@gmail.com
>> >wrote:
>> >
>> >> I am using 4.1.2 and I see that releaseConnection on specific
>> >> put/post/get/delete was removed since 3.1. Do I still have a need to
>> >> release connection?
>> >>
>> >> On Sat, Jan 28, 2012 at 10:34 AM, Mohit Anchlia <mohitanchlia@gmail.com
>> >
>> >> wrote:
>> >> > I found that we are not calling releaseConnection and I think it's
>> >> > somehow related to that. But it still doesn't explain the below
>> >> > behaviour where B responded 10 secs before A timedout. Is this some
>> >> > kind of a race condition when releaseConnection is not called?
>> >> >
>> >> > On Fri, Jan 27, 2012 at 4:07 PM, Mohit Anchlia <
>> mohitanchlia@gmail.com>
>> >> wrote:
>> >> >> We are seeing a wierd behaviour and I am wondering if some kind of
>> >> >> session stickyness might be in play.
>> >> >>
>> >> >> We use HttpClient in Jboss to send post request from A -> B, then B
>> ->
>> >> >> replies with 404 but after 15 secs (timeout on the request) we get
>> >> >> below timeout even though B -> replied to A in few millisecs. I can
>> >> >> see in B (apache) logs that response was sent in few ms. So don't
>> >> >> understand what is causing the timeout and why.
>> >> >>
>> >> >> java.net.SocketTimeoutException: Read timed out
>> >> >> at java.net.SocketInputStream.socketRead0(Native Method)
>> >> >> at java.net.SocketInputStream.read(SocketInputStream.java:129)
>> >> >> at
>> >> com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
>> >> >> at
>> >> com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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: Your thoughts on Readtimeout - releaseConnection
Posted by Karthik K <os...@gmail.com>.
On Mon, Jan 30, 2012 at 5:20 PM, Mohit Anchlia <mo...@gmail.com>wrote:
> On Mon, Jan 30, 2012 at 2:07 PM, Karthik K <os...@gmail.com> wrote:
> > We would still need to release the http connections and the resources for
> > the http response.
> >
> > See the patch for HTTPCLIENT-1159 for details: ( 1) shutting down
> > connection manager and 2) closing stream of http entity as part of
> response
> > ).
>
> Few follow up questions:
>
> 1) shutdown is required only when shutting down the app, correct? I
> mean is shutdown is required after every http request?
>
True. shutdown of a (http)client is a 1-time effort ( depending on the
connection manager, assuming that it is thread-safe).
> 2) I am using EntityUtils.toByteArray(entity), So how do I close the
> stream in this case?
>
entity has an InputStream in it, and you can 'consumeContent' off the same.
>
> >
> > While the patch comes in 4.2 in the future, we need to do the equivalent
> of
> > the same when releasing connections though, for httpclient < 4.2 .
> >
> > --
> > Karthik.
> >
> >
> > On Mon, Jan 30, 2012 at 9:35 AM, Mohit Anchlia <mohitanchlia@gmail.com
> >wrote:
> >
> >> I am using 4.1.2 and I see that releaseConnection on specific
> >> put/post/get/delete was removed since 3.1. Do I still have a need to
> >> release connection?
> >>
> >> On Sat, Jan 28, 2012 at 10:34 AM, Mohit Anchlia <mohitanchlia@gmail.com
> >
> >> wrote:
> >> > I found that we are not calling releaseConnection and I think it's
> >> > somehow related to that. But it still doesn't explain the below
> >> > behaviour where B responded 10 secs before A timedout. Is this some
> >> > kind of a race condition when releaseConnection is not called?
> >> >
> >> > On Fri, Jan 27, 2012 at 4:07 PM, Mohit Anchlia <
> mohitanchlia@gmail.com>
> >> wrote:
> >> >> We are seeing a wierd behaviour and I am wondering if some kind of
> >> >> session stickyness might be in play.
> >> >>
> >> >> We use HttpClient in Jboss to send post request from A -> B, then B
> ->
> >> >> replies with 404 but after 15 secs (timeout on the request) we get
> >> >> below timeout even though B -> replied to A in few millisecs. I can
> >> >> see in B (apache) logs that response was sent in few ms. So don't
> >> >> understand what is causing the timeout and why.
> >> >>
> >> >> java.net.SocketTimeoutException: Read timed out
> >> >> at java.net.SocketInputStream.socketRead0(Native Method)
> >> >> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> >> >> at
> >> com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
> >> >> at
> >> com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
> >>
> >> ---------------------------------------------------------------------
> >> 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: Your thoughts on Readtimeout - releaseConnection
Posted by Mohit Anchlia <mo...@gmail.com>.
On Mon, Jan 30, 2012 at 2:07 PM, Karthik K <os...@gmail.com> wrote:
> We would still need to release the http connections and the resources for
> the http response.
>
> See the patch for HTTPCLIENT-1159 for details: ( 1) shutting down
> connection manager and 2) closing stream of http entity as part of response
> ).
Few follow up questions:
1) shutdown is required only when shutting down the app, correct? I
mean is shutdown is required after every http request?
2) I am using EntityUtils.toByteArray(entity), So how do I close the
stream in this case?
>
> While the patch comes in 4.2 in the future, we need to do the equivalent of
> the same when releasing connections though, for httpclient < 4.2 .
>
> --
> Karthik.
>
>
> On Mon, Jan 30, 2012 at 9:35 AM, Mohit Anchlia <mo...@gmail.com>wrote:
>
>> I am using 4.1.2 and I see that releaseConnection on specific
>> put/post/get/delete was removed since 3.1. Do I still have a need to
>> release connection?
>>
>> On Sat, Jan 28, 2012 at 10:34 AM, Mohit Anchlia <mo...@gmail.com>
>> wrote:
>> > I found that we are not calling releaseConnection and I think it's
>> > somehow related to that. But it still doesn't explain the below
>> > behaviour where B responded 10 secs before A timedout. Is this some
>> > kind of a race condition when releaseConnection is not called?
>> >
>> > On Fri, Jan 27, 2012 at 4:07 PM, Mohit Anchlia <mo...@gmail.com>
>> wrote:
>> >> We are seeing a wierd behaviour and I am wondering if some kind of
>> >> session stickyness might be in play.
>> >>
>> >> We use HttpClient in Jboss to send post request from A -> B, then B ->
>> >> replies with 404 but after 15 secs (timeout on the request) we get
>> >> below timeout even though B -> replied to A in few millisecs. I can
>> >> see in B (apache) logs that response was sent in few ms. So don't
>> >> understand what is causing the timeout and why.
>> >>
>> >> java.net.SocketTimeoutException: Read timed out
>> >> at java.net.SocketInputStream.socketRead0(Native Method)
>> >> at java.net.SocketInputStream.read(SocketInputStream.java:129)
>> >> at
>> com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
>> >> at
>> com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
>>
>> ---------------------------------------------------------------------
>> 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: Your thoughts on Readtimeout - releaseConnection
Posted by Karthik K <os...@gmail.com>.
We would still need to release the http connections and the resources for
the http response.
See the patch for HTTPCLIENT-1159 for details: ( 1) shutting down
connection manager and 2) closing stream of http entity as part of response
).
While the patch comes in 4.2 in the future, we need to do the equivalent of
the same when releasing connections though, for httpclient < 4.2 .
--
Karthik.
On Mon, Jan 30, 2012 at 9:35 AM, Mohit Anchlia <mo...@gmail.com>wrote:
> I am using 4.1.2 and I see that releaseConnection on specific
> put/post/get/delete was removed since 3.1. Do I still have a need to
> release connection?
>
> On Sat, Jan 28, 2012 at 10:34 AM, Mohit Anchlia <mo...@gmail.com>
> wrote:
> > I found that we are not calling releaseConnection and I think it's
> > somehow related to that. But it still doesn't explain the below
> > behaviour where B responded 10 secs before A timedout. Is this some
> > kind of a race condition when releaseConnection is not called?
> >
> > On Fri, Jan 27, 2012 at 4:07 PM, Mohit Anchlia <mo...@gmail.com>
> wrote:
> >> We are seeing a wierd behaviour and I am wondering if some kind of
> >> session stickyness might be in play.
> >>
> >> We use HttpClient in Jboss to send post request from A -> B, then B ->
> >> replies with 404 but after 15 secs (timeout on the request) we get
> >> below timeout even though B -> replied to A in few millisecs. I can
> >> see in B (apache) logs that response was sent in few ms. So don't
> >> understand what is causing the timeout and why.
> >>
> >> java.net.SocketTimeoutException: Read timed out
> >> at java.net.SocketInputStream.socketRead0(Native Method)
> >> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> >> at
> com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
> >> at
> com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>