Tcp keepalive connection not failover


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

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

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

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:

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

    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 check inter 500 fall 1 rise 1 weight 1
    server  lbb-v8y2j191 check inter 500 fall 1 rise 1 weight 1

To the backend section, add:

default-server on-marked-down shutdown-sessions

Also see:

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