Hi,

I've been trying to investigate why we are having lots (tens per second) of
following lines in our log

May 15 11:33:11 localhost haproxy[17618]: XX.XX.179.70:28366
[15/May/2019:11:33:11.430] fe_http~ be_xxxx/s2 0/0/0/-1/3 -1 505 - - SD--
120/120/2/2/0 0/0 {api.xx.io|Ruby/2.6.3|10853} {} "POST /api/v3/xxxx
HTTP/1.1"

which basically means that our Go backend immediately closes the connection
without a response.

After some investigation it turns out that Haproxy proxies "Connection:
close" from the client to Go server and Go closes the connection after
serving the request. But it looks like haproxy keeps using the connection
to serve the next request.

Adding `http-request set-header Connection keep-alive` or `http-request
del-header Connection` fixes the problem. Go does not see `Connection:
close`, therefore Go does not close the connection, and haproxy does not
get an error writing to a closed connection.

All that is true for Haproxy 1.8.20 and Haproxy 1.9.8 with option
http-keep-alive
<https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#option%20http-keep-alive>
(which
is the default I know). Does that make sense?

TBH I would expect haproxy to either remove `Connection: close` (preferred)
or to not reuse the connection. How it is working now is confusing
especially since docs/tutorials say that all you need is option
http-keep-alive
<https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#option%20http-keep-alive>
(which
is the default).

Reply via email to