Hi,

On Thu, Apr 19, 2012 at 08:34:21PM +0530, varoun p wrote:
> On Thu, Apr 19, 2012 at 4:53 PM, varoun p <var...@gmail.com> wrote:
> > Hello,
> >
> > I have HAProxy fronting a few backend servers. For one backend in
> > particular, HAproxy returns a HTTP 502 - bad gateway.
> >
> > As an example -
> >
> > $ curl -v http://felb-use1d-xxxxxxxxxx.us-east-1.elb.amazonaws.com/signin
> > * About to connect() to
> > felb-use1d-xxxxxxxxxx.us-east-1.elb.amazonaws.com port 80 (#0)
> > *   Trying xx.xx.xx.xx... connected
> >> GET /signin HTTP/1.1
> >> User-Agent: curl/7.22.0 (x86_64-apple-darwin11.0.0) libcurl/7.22.0 
> >> OpenSSL/1.0.0e zlib/1.2.6 libidn/1.22
> >> Host: felb-use1d-xxxxxxxxxx.us-east-1.elb.amazonaws.com
> >> Accept: */*
> >>
> > < HTTP/1.1 502 Bad Gateway
> > < Cache-Control: no-cache
> > < Content-Type: text/html
> > < Content-Length: 107
> > < Connection: keep-alive
> > <
> > <html><body><h1>502 Bad Gateway</h1>
> > The server returned an invalid or incomplete response.
> > </body></html>
> > * Connection #0 to host
> > felb-use1d-xxxxxxxxxx.us-east-1.elb.amazonaws.com left intact
> > * Closing connection #0
> > $
> >
> > I see the following in the log -
> > Apr 19 11:13:12 localhost haproxy[16105]: 10.10.50.210:57314
> > [19/Apr/2012:11:12:56.253] http-in userapp/user2-use1c
> > 16421/0/1/-1/16433 502 1652 - - PHNN 2/2/0/0/0 0/0 "GET /signin
> > HTTP/1.1"
> >
> > For another endpoint hosted on the same server, I see the following in
> > the log -
> > Apr 19 11:14:29 localhost haproxy[16105]: 10.10.50.210:57336
> > [19/Apr/2012:11:14:19.260] http-in userapp/user2-use1c
> > 10342/0/1/-1/10384 502 204 - - SHNN 5/5/0/0/0 0/0 "GET /verify
> > HTTP/1.1"
> >
> > Looking at the error stats, this is what I see  -
> >
> > # echo "show errors" |socat stdio /var/lib/haproxy/stats | head
> > Total events captured on [19/Apr/2012:11:16:46.526] : 6
> >
> > [19/Apr/2012:11:13:12.687] backend userapp (#4) : invalid response
> >  src 10.10.50.210, session #182, frontend http-in (#3), server user2-use1c 
> > (#2)
> >  HTTP internal state 26, buffer flags 0x00109002, event #5
> >  response length 1448 bytes, error at position 0:
> >
> >  00000  <!DOCTYPE html>\n
> >  00016  <html lang="en">\n
> >  00033  <head>\n
> > #
> >
> > The backends run tomcat6. The entire infra runs in AWS.
> > Any help in troubleshooting this further is much appreciated.
> > best,
> > -- varoun
> 
> I just noticed that the backend server is not sending the http
> response header, and this is most likely the cause of the problem.

That's exactly the problem. The response does not parse as HTTP, which
is translated by the PH flags. Concerning the SH flags, it means that
sometimes your server closes the connection without sending naything.
It might be possible that it aborts or crashes and restarts from time
to time, this is something you have to check if it happens often.

Willy


Reply via email to