Tcp keepalive connection not failover

Hi,

I’m testing TCP keepalive connection scene, case like:

client A establish a keepalive tcp connection with haproxy port 81:
client 192.168.1.2:1234 -> haproxy 192.168.1.100:81

haproxy has two backends 192.168.1.38:81 and 192.168.1.29:81.
Since haproxy works on non-transparent-proxy mode, haproxy would establish a connection to one of its backend haproxy:
192.168.1.100:4321 -> (assumed backend1 here) backend1 192.168.1.38:81.

When backend1 is down, haproxy can quickly detect and mark backend1 as DOWN.
But haproxy DO NOT failover this connection above, so when the client keeps sending data to haproxy, the client gets HANG, until I bring backend1 back.

I found this but still no solution provided.

I’m using HA-Proxy version 1.6.13 2017/06/18, haproxy.cfg as as followed:

global
    log 127.0.0.1   local0 info
    maxconn 6250
    tune.ssl.default-dh-param 2048
    daemon
    nbproc 1
    stats socket /haproxy/haproxy.1 process 1




defaults
    log     global
    option  dontlognull
    option  redispatch
    retries 3
    maxconn 6250
    timeout connect 5s
    timeout client 50s
    timeout server 50s
    timeout tunnel 5s
    option  tcpka
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

    timeout client-fin 30s


listen  lbl-bijbwloz
    bind *:81
    mode tcp
    option tcplog
    maxconn 6250
    timeout client 50s
    timeout tunnel 5s

    default_backend lbl-bijbwloz_default

backend lbl-bijbwloz_default
    mode tcp
    option tcplog
    balance roundrobin
    timeout server 50s
    timeout tunnel 5s
    timeout check 5000

    server  lbb-811tmjow 192.168.1.29:81 check inter 500 fall 1 rise 1 weight 1
    server  lbb-v8y2j191 192.168.1.38:81 check inter 500 fall 1 rise 1 weight 1

To the backend section, add:

default-server on-marked-down shutdown-sessions

Also see:

https://cbonte.github.io/haproxy-dconv/1.6/configuration.html#5.2-on-marked-down

@lukastribus really thanks for the reply, this has been tested, and is the right way to solve this.