Hello everyone,
I've an issue with HAProxy keeping persistent connections to a backend.
Running HAProxy 1.8.25 (latest build).
My testing config file looks like this:
global
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 2000000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option dontlognull
option log-separate-errors
retries 3
option redispatch
timeout client 30s
timeout connect 4s
timeout http-request 10s
timeout http-keep-alive 2s
timeout queue 5s
timeout tunnel 2m
timeout client-fin 1s
timeout server-fin 1s
frontend frontend
maxconn 2000000
mode http
bind *:443 <some parameters here>
bind *:80
http-request set-header X-Connection Keep-Alive
http-request set-header Connection Keep-Alive
use_backend my_backend
backend my_backend
option http-keep-alive
default-server inter 1s
retries 3
timeout http-request 15s
timeout http-keep-alive 15s
server <server> <ip>:<port>
This is what I see in the pcap:
1 2020-07-23 14:59:22.616924 <haproxy_ip> <backend_ip> TCP 74 64
0.000000000 33506 → <port> [SYN] Seq=0 Win=2048 Len=0 MSS=8961 SACK_PERM=1
TSval=2791663819 TSecr=0 WS=512
2 2020-07-23 14:59:22.617142 <backend_ip> <haproxy_ip> TCP 74 128
0.000218000 <port> → 33506 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460
WS=256 SACK_PERM=1 TSval=285952824 TSecr=2791663819
3 2020-07-23 14:59:22.617159 <haproxy_ip> <backend_ip> TCP 66 64
0.000017000 33506 → <port> [ACK] Seq=1 Ack=1 Win=2048 Len=0
TSval=2791663819 TSecr=285952824
4 2020-07-23 14:59:22.617186 <haproxy_ip> <backend_ip> HTTP 211 64
0.000027000 GET /demo HTTP/1.1
--- HTTP level ---
GET /demo HTTP/1.1
Host: <hostname>
User-Agent: curl/<ver>
Accept: */*
X-Connection: Keep-Alive
Connection: Keep-Alive
---
5 2020-07-23 14:59:22.617436 <backend_ip> <haproxy_ip> TCP 66 128
0.000250000 <port> → 33506 [ACK] Seq=1 Ack=146 Win=2108160 Len=0
TSval=285952824 TSecr=2791663819
6 2020-07-23 14:59:22.624752 <backend_ip> <haproxy_ip> HTTP 581 128
0.007316000 HTTP/1.1 200 OK (text/javascript)
--- HTTP level ---
HTTP/1.1 200 OK
Date: Thu, 23 Jul 2020 14:59:22 GMT
Content-Type: text/javascript; charset=utf-8
Server: <server_name>
Content-Length: 198
Cache-Control: private
---
7 2020-07-23 14:59:22.624756 <haproxy_ip> <backend_ip> TCP 66 64
0.000004000 33506 → <port> [ACK] Seq=146 Ack=516 Win=3584 Len=0
TSval=2791663827 TSecr=285952831
8 2020-07-23 14:59:22.777082 <haproxy_ip> <backend_ip> TCP 66 64
0.152326000 33506 → <port> [RST, ACK] Seq=146 Ack=516 Win=3584 Len=0
TSval=2791663979 TSecr=285952831
As can be seen in the last packet, HAproxy immediately closes the
connection with [RST, ACK] after sending [ACK], and I'm expecting it to
keep the connection alive for a few seconds.
Is it normal behaviour?
Why HA doesn't keep the connection alive?
Thanks,
Zeffy