[Note] 解决使用Workerman和apache创建wss服务时出现的 Error during WebSocket handshake: net::ERR_RESPONSE_HEADERS_TRUNCATED
使用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