[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

參考連接

  1. https://github.com/ratchetphp/Ratchet/issues/645
  2. http://doc.workerman.net/faq/secure-websocket-server.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM