Apache Websocket Proxy Dropped Connections

I'm trying to proxy a websocket through Apache 2.4.7 (running on Ubuntu). The connection is correctly established but if the browser or the server don't send each other data for some time (few minutes) new messages coming from the server are not delivered to the browser.
Furthermore, nor the browser or the service on the server seem to realize the connection is somehow broken (they don't throw any error at all).

How can I configure the server in order to avoid this issue?

This is my configuration:

ProxyRequests Off
ProxyPass /somepath ws://127.0.0.1:6080/ retry=60 keepalive=On timeout=9999 ttl=9999
ProxyPassReverse /somepath ws://127.0.0.1:6080/ retry=60
2

1 Answer

I was having the same issue and resolved it by configuring ProxyWebsocketIdleTimeout, with a value of 300 (seconds). There's documentation here:

Your socket should have a keepalive message. Mine does every 30 seconds, but the connection was dropping because my ProxyWebsocketIdleTimeout directive was obviously less than 30 seconds. I set it to 300 seconds (5 minutes) for good measure and the issue was resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest