You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeff Kohut <je...@gmail.com> on 2015/01/29 23:29:51 UTC

Tomcat sending 411 "Length Required" due to Chunked Transfer Encoding

My first post to Tomcat list, pardon me if I make any mistakes,

Any help you can provide would be greatly appreciated.

I have a Tomcat Server (V 7.0.54) running under Windows 2008 R2 With
Service Pack 1 (and up to date on Security as well as OS patches). That
server is running a vendor supplied group of applications via .war file as
normal. to receive Soap/XML data from remote computer and process and
return data back to calling application.

The remote calling application hosted by IBM Websphere Application Server
(running Axis2 jars) that is sending XML Soap data via a Post to the Tomcat
Web server on port 8080/8443. If the amount of data is relatively small
(i.e. 14 K) we have no problem receiving the data as Websphere is using
Length Http 1.1 header and Tomcat sends the data to the application with no
issue. However as the data gets larger, Websphere begins using Chunked
Transfer Encoding and apparently Tomcat does not seem to like this as it
returns Http 411 "Length Required" message. I have searched Tomcat site,
and Tomcat indicates that is support Chunked encoding (part of the MUST
supported parts of the HTTP 1.1 RFC standard.

My connector in Tomcat is configured:

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

I have tried forcing BIO,NIO, and APR with no luck to see if the
implementations might handle Chunked Encoding differently.

I also have a more complicated 8443 SSL port that also works, until Chunked
encoding is used, and then it also responds with 411 Length Required error.

I am able to replicate the problem by using SoapUI to send the same Soap
formatted XML Data. It works fine sending all sizes of data UNTIL I enable
Chunked Encoding Threshold which is smaller than the XML payload size
(threshold means to not Chunk until data is larger than Threshold), When
Chunking starts, Tomcat responds with 411 Length required.

To finally work around this issue, I have put an Apache 2.4 server in front
of Tomcat, and have enable the mod_proxy_http, and am using an Apache
SetEnv variable setting of : SetEnv proxy-sendcl 1
The proxy-sendcl tells Apache to send the "Length" , and then Tomcat and
application are happy with the data (i.e. no 411 method sent back).

As I stated above, Tomcat indicates it supports Chunked Encoding on it's
site, but it acts as if it is not happy with it.

We have looked at packet traces and it appears that the Chunks are
formatted correctly (we are getting an initial Chunk(s) and then the last
Chunk is zero with Cr Lf following it as it seems to indicate in RFC.

Has anyone else seen this issue and is there any way to alter the Tomcat
behavior with Chunked encoded data?

We found an IBM Websphere article that seems to admit to the problem, but
they indicate that they should not have to offer a method to disable
chunked encoding as some who seem to have encountered this problem suggest.
IBM states that since Http 1.1 mandates support of Chunked Encoding, then
HTTP 1.1. servers should support Chunked encoding correctly. FYI, I took
the time to recreate the problem in C# code, and as soon as I turn on
Chunked Encoding, the 411 errors is present from that application also when
sending data to Tomcat Server.

Thanks,
Jeff

Re: Tomcat sending 411 "Length Required" due to Chunked Transfer Encoding

Posted by Jeff Kohut <je...@gmail.com>.
Thank you for pointing out my error in assuming that it was Tomcat's fault.
I have forwarded the issue to the application vendor to see if they can
fix. I appreciate your time in responding to my question as well as giving
me additional information with which to attempt to debug and/or correct the
issue (i.e. the filter option) I will consider this question closed.
THanks,
Jeff

On Thu, Jan 29, 2015 at 4:58 PM, Konstantin Kolinko <kn...@gmail.com>
wrote:

> 2015-01-30 1:29 GMT+03:00 Jeff Kohut <je...@gmail.com>:
> > My first post to Tomcat list, pardon me if I make any mistakes,
> >
> > Any help you can provide would be greatly appreciated.
> >
> > I have a Tomcat Server (V 7.0.54) running under Windows 2008 R2 With
> > Service Pack 1 (and up to date on Security as well as OS patches). That
> > server is running a vendor supplied group of applications via .war file
> as
> > normal. to receive Soap/XML data from remote computer and process and
> > return data back to calling application.
> >
> > The remote calling application hosted by IBM Websphere Application Server
> > (running Axis2 jars) that is sending XML Soap data via a Post to the
> Tomcat
> > Web server on port 8080/8443. If the amount of data is relatively small
> > (i.e. 14 K) we have no problem receiving the data as Websphere is using
> > Length Http 1.1 header and Tomcat sends the data to the application with
> no
> > issue. However as the data gets larger, Websphere begins using Chunked
> > Transfer Encoding and apparently Tomcat does not seem to like this as it
> > returns Http 411 "Length Required" message. I have searched Tomcat site,
> > and Tomcat indicates that is support Chunked encoding (part of the MUST
> > supported parts of the HTTP 1.1 RFC standard.
> >
> > My connector in Tomcat is configured:
> >
> >     <Connector port="8080" protocol="HTTP/1.1"
> >                connectionTimeout="20000"
> >                redirectPort="8443" />
> >
> > I have tried forcing BIO,NIO, and APR with no luck to see if the
> > implementations might handle Chunked Encoding differently.
> >
> > I also have a more complicated 8443 SSL port that also works, until
> Chunked
> > encoding is used, and then it also responds with 411 Length Required
> error.
> >
> > I am able to replicate the problem by using SoapUI to send the same Soap
> > formatted XML Data. It works fine sending all sizes of data UNTIL I
> enable
> > Chunked Encoding Threshold which is smaller than the XML payload size
> > (threshold means to not Chunk until data is larger than Threshold), When
> > Chunking starts, Tomcat responds with 411 Length required.
> >
> > To finally work around this issue, I have put an Apache 2.4 server in
> front
> > of Tomcat, and have enable the mod_proxy_http, and am using an Apache
> > SetEnv variable setting of : SetEnv proxy-sendcl 1
> > The proxy-sendcl tells Apache to send the "Length" , and then Tomcat and
> > application are happy with the data (i.e. no 411 method sent back).
> >
> > As I stated above, Tomcat indicates it supports Chunked Encoding on it's
> > site, but it acts as if it is not happy with it.
> >
> > We have looked at packet traces and it appears that the Chunks are
> > formatted correctly (we are getting an initial Chunk(s) and then the last
> > Chunk is zero with Cr Lf following it as it seems to indicate in RFC.
> >
> > Has anyone else seen this issue and is there any way to alter the Tomcat
> > behavior with Chunked encoded data?
> >
> > We found an IBM Websphere article that seems to admit to the problem, but
> > they indicate that they should not have to offer a method to disable
> > chunked encoding as some who seem to have encountered this problem
> suggest.
> > IBM states that since Http 1.1 mandates support of Chunked Encoding, then
> > HTTP 1.1. servers should support Chunked encoding correctly. FYI, I took
> > the time to recreate the problem in C# code, and as soon as I turn on
> > Chunked Encoding, the 411 errors is present from that application also
> when
> > sending data to Tomcat Server.
>
>
> Tomcat 7 does not send status code 411 (a constant is declared in
> HttpServletResponse class but it is never used). That response code is
> coming from a web application that you are using.
>
> You may try debugging.
> http://wiki.apache.org/tomcat/FAQ/Developing#Debugging
> with a breakpoint on sendError(int,String), setStatus(int) methods of
> org.apache.catalina.connector.Response.
>
> It should be possible to implement a javax.servlet.Filter to cache a
> request and feed it to the web application for further processing, but
> it would be better to fix the web application itself.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat sending 411 "Length Required" due to Chunked Transfer Encoding

Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-01-30 1:29 GMT+03:00 Jeff Kohut <je...@gmail.com>:
> My first post to Tomcat list, pardon me if I make any mistakes,
>
> Any help you can provide would be greatly appreciated.
>
> I have a Tomcat Server (V 7.0.54) running under Windows 2008 R2 With
> Service Pack 1 (and up to date on Security as well as OS patches). That
> server is running a vendor supplied group of applications via .war file as
> normal. to receive Soap/XML data from remote computer and process and
> return data back to calling application.
>
> The remote calling application hosted by IBM Websphere Application Server
> (running Axis2 jars) that is sending XML Soap data via a Post to the Tomcat
> Web server on port 8080/8443. If the amount of data is relatively small
> (i.e. 14 K) we have no problem receiving the data as Websphere is using
> Length Http 1.1 header and Tomcat sends the data to the application with no
> issue. However as the data gets larger, Websphere begins using Chunked
> Transfer Encoding and apparently Tomcat does not seem to like this as it
> returns Http 411 "Length Required" message. I have searched Tomcat site,
> and Tomcat indicates that is support Chunked encoding (part of the MUST
> supported parts of the HTTP 1.1 RFC standard.
>
> My connector in Tomcat is configured:
>
>     <Connector port="8080" protocol="HTTP/1.1"
>                connectionTimeout="20000"
>                redirectPort="8443" />
>
> I have tried forcing BIO,NIO, and APR with no luck to see if the
> implementations might handle Chunked Encoding differently.
>
> I also have a more complicated 8443 SSL port that also works, until Chunked
> encoding is used, and then it also responds with 411 Length Required error.
>
> I am able to replicate the problem by using SoapUI to send the same Soap
> formatted XML Data. It works fine sending all sizes of data UNTIL I enable
> Chunked Encoding Threshold which is smaller than the XML payload size
> (threshold means to not Chunk until data is larger than Threshold), When
> Chunking starts, Tomcat responds with 411 Length required.
>
> To finally work around this issue, I have put an Apache 2.4 server in front
> of Tomcat, and have enable the mod_proxy_http, and am using an Apache
> SetEnv variable setting of : SetEnv proxy-sendcl 1
> The proxy-sendcl tells Apache to send the "Length" , and then Tomcat and
> application are happy with the data (i.e. no 411 method sent back).
>
> As I stated above, Tomcat indicates it supports Chunked Encoding on it's
> site, but it acts as if it is not happy with it.
>
> We have looked at packet traces and it appears that the Chunks are
> formatted correctly (we are getting an initial Chunk(s) and then the last
> Chunk is zero with Cr Lf following it as it seems to indicate in RFC.
>
> Has anyone else seen this issue and is there any way to alter the Tomcat
> behavior with Chunked encoded data?
>
> We found an IBM Websphere article that seems to admit to the problem, but
> they indicate that they should not have to offer a method to disable
> chunked encoding as some who seem to have encountered this problem suggest.
> IBM states that since Http 1.1 mandates support of Chunked Encoding, then
> HTTP 1.1. servers should support Chunked encoding correctly. FYI, I took
> the time to recreate the problem in C# code, and as soon as I turn on
> Chunked Encoding, the 411 errors is present from that application also when
> sending data to Tomcat Server.


Tomcat 7 does not send status code 411 (a constant is declared in
HttpServletResponse class but it is never used). That response code is
coming from a web application that you are using.

You may try debugging.
http://wiki.apache.org/tomcat/FAQ/Developing#Debugging
with a breakpoint on sendError(int,String), setStatus(int) methods of
org.apache.catalina.connector.Response.

It should be possible to implement a javax.servlet.Filter to cache a
request and feed it to the web application for further processing, but
it would be better to fix the web application itself.

Best regards,
Konstantin Kolinko

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


Re: Tomcat sending 411 "Length Required" due to Chunked Transfer Encoding

Posted by Jeff Kohut <je...@gmail.com>.
Thank you for pointing out my error in assuming that it was Tomcat's fault.
I have forwarded the issue to the application vendor to see if they can
fix. I appreciate your time in responding to my question. I will consider
this questions closed.

On Thu, Jan 29, 2015 at 5:02 PM, Mark Thomas <ma...@apache.org> wrote:

> On 29/01/2015 22:29, Jeff Kohut wrote:
> > My first post to Tomcat list, pardon me if I make any mistakes,
> >
> > Any help you can provide would be greatly appreciated.
> >
> > I have a Tomcat Server (V 7.0.54) running under Windows 2008 R2 With
> > Service Pack 1 (and up to date on Security as well as OS patches). That
> > server is running a vendor supplied group of applications via .war file
> as
> > normal. to receive Soap/XML data from remote computer and process and
> > return data back to calling application.
> >
> > The remote calling application hosted by IBM Websphere Application Server
> > (running Axis2 jars) that is sending XML Soap data via a Post to the
> Tomcat
> > Web server on port 8080/8443. If the amount of data is relatively small
> > (i.e. 14 K) we have no problem receiving the data as Websphere is using
> > Length Http 1.1 header and Tomcat sends the data to the application with
> no
> > issue. However as the data gets larger, Websphere begins using Chunked
> > Transfer Encoding and apparently Tomcat does not seem to like this as it
> > returns Http 411 "Length Required" message.
>
> <snip/>
>
> The mistake you have made is assuming that it is Tomcat internal code
> that is returning the 411. It isn't. Tomcat never sends that response
> code. It is the application that is processing the data and failing to
> handle the lack of content-length when chunked encoding is used.
>
> For the record, Tomcat handles chunked request bodies quite happily and
> we have a bunch of unit tests that cover this.
>
> You need to complain to the vendor that provides the applications you
> are running on your Tomcat instance.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat sending 411 "Length Required" due to Chunked Transfer Encoding

Posted by Mark Thomas <ma...@apache.org>.
On 29/01/2015 22:29, Jeff Kohut wrote:
> My first post to Tomcat list, pardon me if I make any mistakes,
> 
> Any help you can provide would be greatly appreciated.
> 
> I have a Tomcat Server (V 7.0.54) running under Windows 2008 R2 With
> Service Pack 1 (and up to date on Security as well as OS patches). That
> server is running a vendor supplied group of applications via .war file as
> normal. to receive Soap/XML data from remote computer and process and
> return data back to calling application.
> 
> The remote calling application hosted by IBM Websphere Application Server
> (running Axis2 jars) that is sending XML Soap data via a Post to the Tomcat
> Web server on port 8080/8443. If the amount of data is relatively small
> (i.e. 14 K) we have no problem receiving the data as Websphere is using
> Length Http 1.1 header and Tomcat sends the data to the application with no
> issue. However as the data gets larger, Websphere begins using Chunked
> Transfer Encoding and apparently Tomcat does not seem to like this as it
> returns Http 411 "Length Required" message.

<snip/>

The mistake you have made is assuming that it is Tomcat internal code
that is returning the 411. It isn't. Tomcat never sends that response
code. It is the application that is processing the data and failing to
handle the lack of content-length when chunked encoding is used.

For the record, Tomcat handles chunked request bodies quite happily and
we have a bunch of unit tests that cover this.

You need to complain to the vendor that provides the applications you
are running on your Tomcat instance.

Mark

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