You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Santosh Gangadhar <sa...@wirkle.com> on 2009/03/06 12:56:39 UTC

Problem using chunked encoding - request thread cleanup

Hi All,
The application we are developing has a sender which pushes indefinite
binary data to the web application  hosted in Tomcat. The web application is
supposed to consumes an un-predefined limit of data per connection and
stop.

The sender is implemented using Http client and uses InputStreamEntitiy with
chunked encoding. It pushes the data to a PushServlet on the server. The
after PushServlet is done consuming data, it returns from the doPost(). But
the client keeps running because Tomcat as such does not close the stream.
Analyzing the thread dump reveals that it is stuck in cleanup where it tries
to read out the input stream. Following stacktrace talks more where exactly
it gets stuck.

java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:129)
org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:747)
org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:777)
org.apache.coyote.http11.filters.ChunkedInputFilter.readBytes(ChunkedInputFilter.java:225)
org.apache.coyote.http11.filters.ChunkedInputFilter.parseCRLF(ChunkedInputFilter.java:293)
org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:125)
org.apache.coyote.http11.filters.ChunkedInputFilter.end(ChunkedInputFilter.java:179)
org.apache.coyote.http11.InternalInputBuffer.endRequest(InternalInputBuffer.java:368)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
java.lang.Thread.run(Thread.java:619)

Is this a bug? If not what is the right way to solve it? Is this related to
the Expect: 100 continue mechanism?

Thanks,
Santosh.

Re: Problem using chunked encoding - request thread cleanup

Posted by Santosh Gangadhar <sa...@wirkle.com>.
We are sorting to a workaround specific to the implementation for now.
Hopefully, the upcoming release of Tomcat will help.

Thanks all.
Santosh.

On Sat, Mar 7, 2009 at 8:54 AM, Martin Gainty <mg...@hotmail.com> wrote:

>
>
> _________________________________________________________________
> Windows Live™ Groups: Create an online spot for your favorite groups to
> meet.
> http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Santosh Gangadhar
Technical Lead, Wirkle
http://www.wirkle.com
+91 989.902.2981 (Mobile)

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wirkle is a leading product engineering firm focused on developing software
products for the mobile including telecom grade client/server platforms, SMS
applications and Mobile Internet (WAP). The Company has designed, developed,
maintained, supported, tested and ported several mobile platforms for
hundreds of handsets of Nokia, Sony Ericsson, Samsung, LG, Motorola,
Blackberry, Pocket PC and iPhone.

Wirkle's expertise in the mobile space spans Social Networking, Instant
Messaging, Location Based Services, Multimedia Streaming, Banking,
Enterprise applications, Payments,  Barcode Scanning and beyond. Millions of
mobile users across the globe today are using products developed by Wirkle
through various carriers across multiple geographies including North America
– AT&T, Sprint/Nextel, Boost Mobile; Europe – Telenor; Asia – Airtel, Idea
and more. For more information please visit: www.wirkle.com

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

RE: Problem using chunked encoding - request thread cleanup

Posted by Martin Gainty <mg...@hotmail.com>.

_________________________________________________________________
Windows Live™ Groups: Create an online spot for your favorite groups to meet.
http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem using chunked encoding - request thread cleanup

Posted by Bill Barker <wb...@wilshire.com>.
"Santosh Gangadhar" <sa...@wirkle.com> wrote in message 
news:6a0454270903060913x1e8a7914qbf9de5274423624c@mail.gmail.com...
> On Fri, Mar 6, 2009 at 8:50 PM, Caldarale, Charles R <
> Chuck.Caldarale@unisys.com> wrote:
>
>> > From: Santosh Gangadhar [mailto:santosh@wirkle.com]
>> > Subject: Re: Problem using chunked encoding - request thread cleanup
>> >
>> > But the client keeps running because Tomcat as such does
>> > not close the stream.
>>
>> Perhaps I'm missing something, but why would Tomcat ever close the
>> chunked-encoding input stream?  Isn't it the responsibility of the client 
>> to
>> indicate there's no more data and close the stream?
>>
>>  - Chuck
>>
>>
>> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>> MATERIAL and is thus for use only by the intended recipient. If you 
>> received
>> this in error, please contact the sender and delete the e-mail and its
>> attachments from all computers.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>> The client is pushing an mjpeg stream to a servlet on the server. Its 
>> upto
> the server when to stop pushing the stream. The client cannot indicate 
> when
> to end the stream. May be HTTP is not being used aptly here. But still, is
> there a way for the servlet to end the stream. ServletInputStream.close()
> does not help either.
> Thanks,
> Santosh.
>
No currently released version of Tomcat does what you want.  But the 
upcoming 6.0.19 release will if the Servlet sends back a status code that 
will cause it to close the connection to the client (e.g. 
HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE), or throws an Exception 
that isn't handled by an error page. 




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem using chunked encoding - request thread cleanup

Posted by Santosh Gangadhar <sa...@wirkle.com>.
On Fri, Mar 6, 2009 at 8:50 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Santosh Gangadhar [mailto:santosh@wirkle.com]
> > Subject: Re: Problem using chunked encoding - request thread cleanup
> >
> > But the client keeps running because Tomcat as such does
> > not close the stream.
>
> Perhaps I'm missing something, but why would Tomcat ever close the
> chunked-encoding input stream?  Isn't it the responsibility of the client to
> indicate there's no more data and close the stream?
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> The client is pushing an mjpeg stream to a servlet on the server. Its upto
the server when to stop pushing the stream. The client cannot indicate when
to end the stream. May be HTTP is not being used aptly here. But still, is
there a way for the servlet to end the stream. ServletInputStream.close()
does not help either.
Thanks,
Santosh.

RE: Problem using chunked encoding - request thread cleanup

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Santosh Gangadhar [mailto:santosh@wirkle.com]
> Subject: Re: Problem using chunked encoding - request thread cleanup
>
> But the client keeps running because Tomcat as such does
> not close the stream.

Perhaps I'm missing something, but why would Tomcat ever close the chunked-encoding input stream?  Isn't it the responsibility of the client to indicate there's no more data and close the stream?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem using chunked encoding - request thread cleanup

Posted by Santosh Gangadhar <sa...@wirkle.com>.
Tried with JBoss 4.0.3 which internally uses Tomcat 5.5. Same behavior there
as well.
Santosh.

On Fri, Mar 6, 2009 at 5:56 PM, Santosh Gangadhar <sa...@wirkle.com>wrote:

> Sorry, missed to give the details.
> Tomcat: 5.0.28
> Java: 1.6.0_04
> Commons http client: 3.0.1
>
> I'll try the latest Tomcat 6.0.
>
> Thanks,
> Santosh.
>
>
> On Fri, Mar 6, 2009 at 5:32 PM, Rainer Jung <ra...@kippdata.de>wrote:
>
>> Not answering your question, but which exact Tomcat version are you using?
>> There have been a couple of code changes around those connector classes.
>>
>> Regards,
>>
>> Rainer
>>
>>
>> On 06.03.2009 12:56, Santosh Gangadhar wrote:
>>
>>> Hi All,
>>> The application we are developing has a sender which pushes indefinite
>>> binary data to the web application  hosted in Tomcat. The web application
>>> is
>>> supposed to consumes an un-predefined limit of data per connection and
>>> stop.
>>>
>>> The sender is implemented using Http client and uses InputStreamEntitiy
>>> with
>>> chunked encoding. It pushes the data to a PushServlet on the server. The
>>> after PushServlet is done consuming data, it returns from the doPost().
>>> But
>>> the client keeps running because Tomcat as such does not close the
>>> stream.
>>> Analyzing the thread dump reveals that it is stuck in cleanup where it
>>> tries
>>> to read out the input stream. Following stacktrace talks more where
>>> exactly
>>> it gets stuck.
>>>
>>> java.net.SocketInputStream.socketRead0(Native Method)
>>> java.net.SocketInputStream.read(SocketInputStream.java:129)
>>>
>>> org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:747)
>>>
>>> org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:777)
>>>
>>> org.apache.coyote.http11.filters.ChunkedInputFilter.readBytes(ChunkedInputFilter.java:225)
>>>
>>> org.apache.coyote.http11.filters.ChunkedInputFilter.parseCRLF(ChunkedInputFilter.java:293)
>>>
>>> org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:125)
>>>
>>> org.apache.coyote.http11.filters.ChunkedInputFilter.end(ChunkedInputFilter.java:179)
>>>
>>> org.apache.coyote.http11.InternalInputBuffer.endRequest(InternalInputBuffer.java:368)
>>>
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)
>>>
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>>>
>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>>>
>>> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
>>> java.lang.Thread.run(Thread.java:619)
>>>
>>> Is this a bug? If not what is the right way to solve it? Is this related
>>> to
>>> the Expect: 100 continue mechanism?
>>>
>>> Thanks,
>>> Santosh.
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> --
> Santosh Gangadhar
> Technical Lead, Wirkle
> http://www.wirkle.com
> +91 989.902.2981 (Mobile)
>
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Wirkle is a leading product engineering firm focused on developing software
> products for the mobile including telecom grade client/server platforms, SMS
> applications and Mobile Internet (WAP). The Company has designed, developed,
> maintained, supported, tested and ported several mobile platforms for
> hundreds of handsets of Nokia, Sony Ericsson, Samsung, LG, Motorola,
> Blackberry, Pocket PC and iPhone.
>
> Wirkle's expertise in the mobile space spans Social Networking, Instant
> Messaging, Location Based Services, Multimedia Streaming, Banking,
> Enterprise applications, Payments,  Barcode Scanning and beyond. Millions of
> mobile users across the globe today are using products developed by Wirkle
> through various carriers across multiple geographies including North America
> – AT&T, Sprint/Nextel, Boost Mobile; Europe – Telenor; Asia – Airtel, Idea
> and more. For more information please visit: www.wirkle.com
>
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>


-- 
Santosh Gangadhar
Technical Lead, Wirkle
http://www.wirkle.com
+91 989.902.2981 (Mobile)

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wirkle is a leading product engineering firm focused on developing software
products for the mobile including telecom grade client/server platforms, SMS
applications and Mobile Internet (WAP). The Company has designed, developed,
maintained, supported, tested and ported several mobile platforms for
hundreds of handsets of Nokia, Sony Ericsson, Samsung, LG, Motorola,
Blackberry, Pocket PC and iPhone.

Wirkle's expertise in the mobile space spans Social Networking, Instant
Messaging, Location Based Services, Multimedia Streaming, Banking,
Enterprise applications, Payments,  Barcode Scanning and beyond. Millions of
mobile users across the globe today are using products developed by Wirkle
through various carriers across multiple geographies including North America
– AT&T, Sprint/Nextel, Boost Mobile; Europe – Telenor; Asia – Airtel, Idea
and more. For more information please visit: www.wirkle.com

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Re: Problem using chunked encoding - request thread cleanup

Posted by Santosh Gangadhar <sa...@wirkle.com>.
Sorry, missed to give the details.
Tomcat: 5.0.28
Java: 1.6.0_04
Commons http client: 3.0.1

I'll try the latest Tomcat 6.0.

Thanks,
Santosh.

On Fri, Mar 6, 2009 at 5:32 PM, Rainer Jung <ra...@kippdata.de> wrote:

> Not answering your question, but which exact Tomcat version are you using?
> There have been a couple of code changes around those connector classes.
>
> Regards,
>
> Rainer
>
>
> On 06.03.2009 12:56, Santosh Gangadhar wrote:
>
>> Hi All,
>> The application we are developing has a sender which pushes indefinite
>> binary data to the web application  hosted in Tomcat. The web application
>> is
>> supposed to consumes an un-predefined limit of data per connection and
>> stop.
>>
>> The sender is implemented using Http client and uses InputStreamEntitiy
>> with
>> chunked encoding. It pushes the data to a PushServlet on the server. The
>> after PushServlet is done consuming data, it returns from the doPost().
>> But
>> the client keeps running because Tomcat as such does not close the stream.
>> Analyzing the thread dump reveals that it is stuck in cleanup where it
>> tries
>> to read out the input stream. Following stacktrace talks more where
>> exactly
>> it gets stuck.
>>
>> java.net.SocketInputStream.socketRead0(Native Method)
>> java.net.SocketInputStream.read(SocketInputStream.java:129)
>>
>> org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:747)
>>
>> org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:777)
>>
>> org.apache.coyote.http11.filters.ChunkedInputFilter.readBytes(ChunkedInputFilter.java:225)
>>
>> org.apache.coyote.http11.filters.ChunkedInputFilter.parseCRLF(ChunkedInputFilter.java:293)
>>
>> org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:125)
>>
>> org.apache.coyote.http11.filters.ChunkedInputFilter.end(ChunkedInputFilter.java:179)
>>
>> org.apache.coyote.http11.InternalInputBuffer.endRequest(InternalInputBuffer.java:368)
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)
>>
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>>
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>>
>> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
>> java.lang.Thread.run(Thread.java:619)
>>
>> Is this a bug? If not what is the right way to solve it? Is this related
>> to
>> the Expect: 100 continue mechanism?
>>
>> Thanks,
>> Santosh.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Santosh Gangadhar
Technical Lead, Wirkle
http://www.wirkle.com
+91 989.902.2981 (Mobile)

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wirkle is a leading product engineering firm focused on developing software
products for the mobile including telecom grade client/server platforms, SMS
applications and Mobile Internet (WAP). The Company has designed, developed,
maintained, supported, tested and ported several mobile platforms for
hundreds of handsets of Nokia, Sony Ericsson, Samsung, LG, Motorola,
Blackberry, Pocket PC and iPhone.

Wirkle's expertise in the mobile space spans Social Networking, Instant
Messaging, Location Based Services, Multimedia Streaming, Banking,
Enterprise applications, Payments,  Barcode Scanning and beyond. Millions of
mobile users across the globe today are using products developed by Wirkle
through various carriers across multiple geographies including North America
– AT&T, Sprint/Nextel, Boost Mobile; Europe – Telenor; Asia – Airtel, Idea
and more. For more information please visit: www.wirkle.com

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Re: Problem using chunked encoding - request thread cleanup

Posted by Rainer Jung <ra...@kippdata.de>.
Not answering your question, but which exact Tomcat version are you 
using? There have been a couple of code changes around those connector 
classes.

Regards,

Rainer

On 06.03.2009 12:56, Santosh Gangadhar wrote:
> Hi All,
> The application we are developing has a sender which pushes indefinite
> binary data to the web application  hosted in Tomcat. The web application is
> supposed to consumes an un-predefined limit of data per connection and
> stop.
>
> The sender is implemented using Http client and uses InputStreamEntitiy with
> chunked encoding. It pushes the data to a PushServlet on the server. The
> after PushServlet is done consuming data, it returns from the doPost(). But
> the client keeps running because Tomcat as such does not close the stream.
> Analyzing the thread dump reveals that it is stuck in cleanup where it tries
> to read out the input stream. Following stacktrace talks more where exactly
> it gets stuck.
>
> java.net.SocketInputStream.socketRead0(Native Method)
> java.net.SocketInputStream.read(SocketInputStream.java:129)
> org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:747)
> org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:777)
> org.apache.coyote.http11.filters.ChunkedInputFilter.readBytes(ChunkedInputFilter.java:225)
> org.apache.coyote.http11.filters.ChunkedInputFilter.parseCRLF(ChunkedInputFilter.java:293)
> org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:125)
> org.apache.coyote.http11.filters.ChunkedInputFilter.end(ChunkedInputFilter.java:179)
> org.apache.coyote.http11.InternalInputBuffer.endRequest(InternalInputBuffer.java:368)
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
> java.lang.Thread.run(Thread.java:619)
>
> Is this a bug? If not what is the right way to solve it? Is this related to
> the Expect: 100 continue mechanism?
>
> Thanks,
> Santosh.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org