简体   繁体   English

Apache Websocket 代理断开连接

[英]Apache Websocket Proxy dropped connections

I'm trying to proxy a websocket through Apache 2.4.7 (running on Ubuntu).我正在尝试通过 Apache 2.4.7(在 Ubuntu 上运行)代理 websocket。 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

I was having the same issue and resolved it by configuring ProxyWebsocketIdleTimeout , with a value of 300 (seconds).我遇到了同样的问题并通过配置ProxyWebsocketIdleTimeout解决了它,值为 300(秒)。 There's documentation here:https://httpd.apache.org/docs/trunk/mod/mod_proxy_wstunnel.html这里有文档:https ://httpd.apache.org/docs/trunk/mod/mod_proxy_wstunnel.html

Your socket should have a keepalive message.您的套接字应该有一个 keepalive 消息。 Mine does every 30 seconds, but the connection was dropping because my ProxyWebsocketIdleTimeout directive was obviously less than 30 seconds.我的每 30 秒执行一次,但由于我的 ProxyWebsocketIdleTimeout 指令明显少于 30 秒,因此连接中断。 I set it to 300 seconds (5 minutes) for good measure and the issue was resolved.我将其设置为 300 秒(5 分钟)以进行良好测量,问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM