How to close client connections on failover

Hello, I’m using haproxy for the first time and am trying to create an active/standby configuration. The system runs in tcp mode and clients (frontends) use a telecomms protocol which is completely stateful, requiring sessions to be established by first authenticating before other PDUs can then be sent and received. Request/response PDU pairs can be sent/received by either party at either end of the connection/session.

I have failover and fail back working in that if the primary back end goes down or becomes “unhealthy” in any one of various respects, this is detected (using an external check script) the secondary server takes over. If the primary comes back, the secondary is put into standby mode again and the primary resumes its duties.

Due to use of sessions by the telecomms protocol, I need to ensure that when failover happens, connected clients close their TCP/IP connections to haproxy, reconnect and login again (this will of course create a session with the secondary server now that failover has occurred).

Is it possible to configure haproxy to close all TCP/IP connections from clients when failing over? It occurs to me that I could restart haproxy from my external-check script and this would achieve that result but that sounds like a terrible idea and I’m sure there must be something more elegant I could do :slight_smile:

Thanks in anticipation



on-marked-down shutdown-sessions
on-marked-up shutdown-backup-sessions

Perfect! Thank you so much for the quick answer. Much appreciated :slight_smile: