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 David Zhao <da...@gmail.com> on 2008/10/07 22:35:37 UTC
Detecting connection interruptions for uploads
Hi,
I'm using http-client 3.1 in a java desktop client. I've noticed an
issue with doing file uploads while getting connection interrupted,
for example, a wifi connection that is no longer available. When that
happens, my client would freeze in FilePart#sendData where it times
out in the write method of java Socket.
After digging around, I found this article:
http://209.85.173.104/search?q=cache:7lA5d6FTgzYJ:https://lists.spline.inf.fu-berlin.de/lurker/message/20071121.145132.dd820d54.es.html+SocketOutputStream+does+not+time+out&hl=en&ct=clnk&cd=1&gl=us&client=safari
which describes:
------------------------------------
AFAIKS, the actual problem here is:
java.net.SocketOutputStream.write() is
always a blocking operation, and it is also not by the java socket API
to
specify a timeout for write operations. Thus, it is simply not
possible to
return from SocketOutputStream.write() until all data are transferred
or the
TCP Stack gives up.
------------------------------------
Does anyone know of a work around for this issue?
Thanks,
-David
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Detecting connection interruptions for uploads
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2008-10-08 at 11:15 -0700, David Zhao wrote:
> Will switching to HttpClient 4.0 with the NIO option solve this issue?
> Or could I use NIO transport in HttpClient 3.1?
>
David,
Neither HttpClient 3.1 nor HttpClient 4.0 support non-blocking HTTP.
HttpCore (a set of low level components HttpClient 4.0 is based on)
provides NIO based components for the most fundamental transport
aspects. However, HttpCore does not provide support for advanced HTTP
functionality such as state (cookie) management, connection pooling and
authentication.
Oleg
> Thanks,
>
> -David
>
> On Oct 8, 2008, at 8:18 AM, Oleg Kalnichevski wrote:
>
> > On Tue, 2008-10-07 at 13:35 -0700, David Zhao wrote:
> >> Hi,
> >>
> >> I'm using http-client 3.1 in a java desktop client. I've noticed an
> >> issue with doing file uploads while getting connection interrupted,
> >> for example, a wifi connection that is no longer available. When that
> >> happens, my client would freeze in FilePart#sendData where it times
> >> out in the write method of java Socket.
> >>
> >> After digging around, I found this article:
> >> http://209.85.173.104/search?q=cache:7lA5d6FTgzYJ:https://lists.spline.inf.fu-berlin.de/lurker/message/20071121.145132.dd820d54.es.html+SocketOutputStream+does+not+time+out&hl=en&ct=clnk&cd=1&gl=us&client=safari
> >>
> >> which describes:
> >> ------------------------------------
> >> AFAIKS, the actual problem here is:
> >> java.net.SocketOutputStream.write() is
> >> always a blocking operation, and it is also not by the java socket
> >> API
> >> to
> >> specify a timeout for write operations. Thus, it is simply not
> >> possible to
> >> return from SocketOutputStream.write() until all data are transferred
> >> or the
> >> TCP Stack gives up.
> >> ------------------------------------
> >>
> >> Does anyone know of a work around for this issue?
> >>
> >
> > I suspect the only option would be to use a NIO based transport.
> >
> > Oleg
> >
> >> Thanks,
> >>
> >> -David
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Detecting connection interruptions for uploads
Posted by David Zhao <da...@gmail.com>.
Will switching to HttpClient 4.0 with the NIO option solve this issue?
Or could I use NIO transport in HttpClient 3.1?
Thanks,
-David
On Oct 8, 2008, at 8:18 AM, Oleg Kalnichevski wrote:
> On Tue, 2008-10-07 at 13:35 -0700, David Zhao wrote:
>> Hi,
>>
>> I'm using http-client 3.1 in a java desktop client. I've noticed an
>> issue with doing file uploads while getting connection interrupted,
>> for example, a wifi connection that is no longer available. When that
>> happens, my client would freeze in FilePart#sendData where it times
>> out in the write method of java Socket.
>>
>> After digging around, I found this article:
>> http://209.85.173.104/search?q=cache:7lA5d6FTgzYJ:https://lists.spline.inf.fu-berlin.de/lurker/message/20071121.145132.dd820d54.es.html+SocketOutputStream+does+not+time+out&hl=en&ct=clnk&cd=1&gl=us&client=safari
>>
>> which describes:
>> ------------------------------------
>> AFAIKS, the actual problem here is:
>> java.net.SocketOutputStream.write() is
>> always a blocking operation, and it is also not by the java socket
>> API
>> to
>> specify a timeout for write operations. Thus, it is simply not
>> possible to
>> return from SocketOutputStream.write() until all data are transferred
>> or the
>> TCP Stack gives up.
>> ------------------------------------
>>
>> Does anyone know of a work around for this issue?
>>
>
> I suspect the only option would be to use a NIO based transport.
>
> Oleg
>
>> Thanks,
>>
>> -David
>>
>> ---------------------------------------------------------------------
>> 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: Detecting connection interruptions for uploads
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2008-10-07 at 13:35 -0700, David Zhao wrote:
> Hi,
>
> I'm using http-client 3.1 in a java desktop client. I've noticed an
> issue with doing file uploads while getting connection interrupted,
> for example, a wifi connection that is no longer available. When that
> happens, my client would freeze in FilePart#sendData where it times
> out in the write method of java Socket.
>
> After digging around, I found this article:
> http://209.85.173.104/search?q=cache:7lA5d6FTgzYJ:https://lists.spline.inf.fu-berlin.de/lurker/message/20071121.145132.dd820d54.es.html+SocketOutputStream+does+not+time+out&hl=en&ct=clnk&cd=1&gl=us&client=safari
>
> which describes:
> ------------------------------------
> AFAIKS, the actual problem here is:
> java.net.SocketOutputStream.write() is
> always a blocking operation, and it is also not by the java socket API
> to
> specify a timeout for write operations. Thus, it is simply not
> possible to
> return from SocketOutputStream.write() until all data are transferred
> or the
> TCP Stack gives up.
> ------------------------------------
>
> Does anyone know of a work around for this issue?
>
I suspect the only option would be to use a NIO based transport.
Oleg
> Thanks,
>
> -David
>
> ---------------------------------------------------------------------
> 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