Why Are WebSocket Connections Dropping in HAProxy TCP Mode Despite Timeout Settings?

Hello

I am running into an odd issue where long-lived WebSocket connections proxied through HAProxy in TCP mode are getting reset unexpectedly. :slightly_smiling_face:The disconnections occur after a few minutes of idle time; even though I have disabled / extended all relevant timeout settings like timeout client, timeout server,& timeout tunnel. What’s strange is that there’s no clear logging from HAProxy indicating why the connection was dropped. :innocent:

When I connect to the WebSocket backend directly, everything works perfectly even idle connections stay alive indefinitely. But once I put HAProxy in the middle (in TCP mode); the issue arises intermittently. :thinking:

Switching to HTTP mode avoids the problem; but I need raw TCP for binary messaging in this WebSocket implementation, so I can’t use HTTP mode as a workaround. :thinking:

What else should I check? Could there be something lower-level like OS-level TCP keepalive settings, NAT timeouts / HAProxy’s own buffer handling in TCP mode causing silent resets? :thinking: Checked The Four Essential Sections of an HAProxy Configuration guide for reference. While exploring system behavior for projects related to what is Agentic AI; I began noticing frequent WebSocket disconnects when routed through HAProxy in TCP mode.

Has anyone encountered similar behavior? Any ideas or examples would be really helpful.

Thank you !! :slightly_smiling_face:

I suggest you enable logging in the tcplog format and provide a complete log line of a connections that has been closed unexpectatly, along with the full configuration and the output of haproxy -vv.