# Connection persistent

**URL:** <https://discourse.haproxy.org/t/connection-persistent/5287>\
**Category:** Help!\
**Created:** [May 28, 2020, 3:45pm UTC](https://discourse.haproxy.org/t/connection-persistent/5287 "2020-05-28T15:45:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riccardo1987](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@Riccardo1987](https://discourse.haproxy.org/u/Riccardo1987)\
**Post date:** [May 28, 2020, 3:45pm UTC](https://discourse.haproxy.org/t/connection-persistent/5287/1 "2020-05-28T15:45:06Z")

</div>

Hi,  
i have a set up with 3 web server used as backend for HAProxy solution.  
I have 1 server as primary and the other 2 as backup1 and backup 2.  
If the primary goes down new connections are sent at backup 1 as we want to.  
When the primary server comes up again all new connection are sent to him, once again as we want to, but the alredy exsisting one in the backup 1 are truncated.  
Is there a way to let those existing connections one the backup1 server and once those are closed send all the traffic to the primary one?

---

<div class="post-metadata">

**Author:** ![MadEcto](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/madecto/32/1141_2.png) [@MadEcto](https://discourse.haproxy.org/u/MadEcto)\
**Post date:** [May 29, 2020, 7:26am UTC](https://discourse.haproxy.org/t/connection-persistent/5287/2 "2020-05-29T07:26:51Z")

</div>

Hi Riccardo,  
a snippet of your configuration and HAproxy version would be usefull, but I believe you can achieve your goal using `stick-tables` and `stick on` in your backend section.

There’s a great example [here](http://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-stick%20store-response):

```auto
# Learn SSL session ID from both request and response and create affinity.
backend https
    mode tcp
    balance roundrobin
    # maximum SSL session ID length is 32 bytes.
    stick-table type binary len 32 size 30k expire 30m

    acl clienthello req_ssl_hello_type 1
    acl serverhello rep_ssl_hello_type 2

    # use tcp content accepts to detects ssl client and server hello.
    tcp-request inspect-delay 5s
    tcp-request content accept if clienthello

    # no timeout on response inspect delay by default.
    tcp-response content accept if serverhello

    # SSL session ID (SSLID) may be present on a client or server hello.
    # Its length is coded on 1 byte at offset 43 and its value starts
    # at offset 44.

    # Match and learn on request if client hello.
    stick on payload_lv(43,1) if clienthello

    # Learn on response if server hello.
    stick store-response payload_lv(43,1) if serverhello

    server s1 192.168.1.1:443
    server s2 192.168.1.1:443

```
