使用apache代理生成的wss服務常出現 Error during WebSocket handshake: net::ERR_RESPONSE_HEADERS_TRUNCATED
的問題,但多刷新幾次頁面就能連接成功
在官方文檔沒找到辦法,最后在https://github.com/ratchetphp/Ratchet/issues/645找到了解決方案
這個不是Workerman的倉庫,但解決辦法是通用的
I could say that when some client disconnects without default websockt close protocol, ratchet keeps the connection "open", but when a new user connects then ratchet reuses somehow the last "open"(closed) connection...
Because the new client uses a old "active" connection, when it sends the HTTP handshake, ratchet complains because it isn't the default message frame.
是連接的重用導致了這個問題
修改apache的配置文件 conf.d/ssl.conf
在反向代理中增加一個配置 disablereuse=On
,問題解決了
ProxyPass /wss ws://127.0.0.1:8282/wss disablereuse=On
ProxyPassReverse /wss ws://127.0.0.1:8282/wss