[undertow-dev] occasional 502 from Apache HTTP Proxy

Stuart Douglas sdouglas at redhat.com
Sun Jan 18 19:59:15 EST 2015



Edgar Espina wrote:
> I'm not, channel does it.
>
> Problem is present on both. For example, home page has a content-length
> header but jquery.js use chunked.

In general if you are serving static resources you are better off 
setting the content length (slightly more efficient, and the browser can 
display progress on downloads).

>
> Do I have to call .endExchange? or closing the output stream is enough?

Closing the output stream is enough. endExchange is automatically called 
once the call stack returns anyway, unless you have dispatched the 
exchange or started async IO.

The 'connection reset by peer' error in the apache log while reading the 
status like kinda indicates that the request does not even get to this 
point anyway, and the underlying TCP connection is probably being torn 
down somehow.

Do you have any kind of timeouts set? If you have an idle timeout set on 
the listener there is a race where Undertow can close the channel due to 
inactivity just as the front end starts to send a request.

Stuart

>
> Thanks
>
> On Sun, Jan 18, 2015 at 9:48 PM, Stuart Douglas <sdouglas at redhat.com
> <mailto:sdouglas at redhat.com>> wrote:
>
>     Another question, are you setting a content length on the responses?
>     If not the channel will automatically set one if the response fits
>     inside a buffer, otherwise chunked encoding will be used.
>
>     It might be helpful to know if this only happens on chunked, fixed
>     length or both.
>
>     Stuart
>
>     Edgar Espina wrote:
>
>         latest: 1.2.0.Beta8
>
>         On Sun, Jan 18, 2015 at 9:42 PM, Stuart Douglas
>         <sdouglas at redhat.com <mailto:sdouglas at redhat.com>
>         <mailto:sdouglas at redhat.com <mailto:sdouglas at redhat.com>>> wrote:
>
>              Also what version of Undertow are you using?
>
>              Stuart
>
>              ----- Original Message -----
>         >   From: "Edgar Espina" <espina.edgar at gmail.com
>         <mailto:espina.edgar at gmail.com>
>         <mailto:espina.edgar at gmail.com <mailto:espina.edgar at gmail.com>__>>
>         >  To: "Stuart Douglas" <sdouglas at redhat.com
>         <mailto:sdouglas at redhat.com>
>         <mailto:sdouglas at redhat.com <mailto:sdouglas at redhat.com>>>
>         >  Cc: undertow-dev at lists.jboss.org
>         <mailto:undertow-dev at lists.jboss.org>
>         <mailto:undertow-dev at lists.__jboss.org
>         <mailto:undertow-dev at lists.jboss.org>>
>         >  Sent: Monday, 19 January, 2015 11:13:21 AM
>         >  Subject: Re: [undertow-dev] occasional 502 from Apache HTTP Proxy
>         >
>         >  found this in apache:
>         >
>         >  (104) Connection reset by peer: proxy: error reading status
>         line from
>         >  remote server
>         >
>         >  but nothing in undertow.
>         >
>         >  got 502 on HTTP GET. Sometimes while calling the home page / or
>              when page
>         >  loads OK, got 502 on page resources (js, css, images).
>         >
>         >  I call startBlocking and use the outputstream to write the
>              response, when
>         >  everything has been written I call the "outputstream.close"
>              method. Do I
>         >  need to call exchange.endExchange too?
>         >
>         >  Thanks
>         >
>         >  On Sun, Jan 18, 2015 at 8:52 PM, Stuart Douglas
>         <sdouglas at redhat.com <mailto:sdouglas at redhat.com>
>         <mailto:sdouglas at redhat.com <mailto:sdouglas at redhat.com>>> wrote:
>         >
>         >  > Is there any info in the log? Or is there any specific type of
>              request
>         >  > that causes this?
>         >  >
>         >  > Stuart
>         >  >
>         >  >
>         >  > ----- Original Message -----
>         >  > > From: "Edgar Espina" <espina.edgar at gmail.com
>         <mailto:espina.edgar at gmail.com>
>         <mailto:espina.edgar at gmail.com <mailto:espina.edgar at gmail.com>__>>
>          > > > To: undertow-dev at lists.jboss.org
>         <mailto:undertow-dev at lists.jboss.org>
>         <mailto:undertow-dev at lists.__jboss.org
>         <mailto:undertow-dev at lists.jboss.org>>
>          > > > Sent: Monday, 19 January, 2015 9:42:19 AM
>          > > > Subject: [undertow-dev] occasional 502 from Apache HTTP Proxy
>          > > >
>          > > > Hi,
>          > > >
>          > > > I've an Undertow application behind apache reverse proxy,
>              trying to load
>          > > a
>          > > > page displays error 502 proxy error.
>          > > >
>          > > > Still couldn't find why so I wonder if any of you find a
>              similar problem
>          > > with
>          > > > Undertow and Apache.
>          > > >
>          > > > Please note this is our first app on top of Undertow,
>              existing apps
>          > > running
>          > > > on Tomcat/Jetty are OK.
>          > > >
>          > > > Appreciate any help.
>          > > >
>          > > > Thanks
>          > > >
>          > > > --
>          > > > edgar
>          > > >
>          > > > _________________________________________________
>          > > > undertow-dev mailing list
>          > > > undertow-dev at lists.jboss.org
>         <mailto:undertow-dev at lists.jboss.org>
>         <mailto:undertow-dev at lists.__jboss.org
>         <mailto:undertow-dev at lists.jboss.org>>
>         >  > > https://lists.jboss.org/__mailman/listinfo/undertow-dev
>         <https://lists.jboss.org/mailman/listinfo/undertow-dev>
>         >  >
>         >
>         >
>         >
>         >  --
>         >  edgar
>         >
>
>
>
>
>         --
>         edgar
>
>
>
>
> --
> edgar


More information about the undertow-dev mailing list