且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WebSocket 连接到“ws://mydomain.com:8084/?peer_id=123"失败:连接建立错误:net::ERR_CONNECTION_TIMED_OUT

更新时间:2021-08-11 03:25:20

问题是我使用的端口是 8082 和 8083 突然被客户端浏览器阻止了.超时错误准确反映了使用非 80 (HTTP) 或 443 (SSL) 的端口连接到我的 Web 套接字服务器失败的结果.原因可能是防火墙,防病毒软件或任何 HTTP 代理问题.

The problem is the port which I was using are 8082 and 8083 suddenly blocked by client browser. The timeout error reflects exactly the result of failure of the connecting to my web socket server with those ports which isn't 80 (HTTP) or 443 (SSL). The cause maybe the firewall, Antiviruses, or any HTTP proxies issue around.

实际上有很多话题人们会注意到这个问题.最终,我不得不找出配置我的服务器的方法,以将端口 80 的请求反向到两个不同的端口:8080(我的 Apache)和8083(网络套接字).

There are actually many topics where people notice about this problem. Eventually, I had to find out the way to configure my server to reverse the request with port 80 to two different ports: 8080 (my Apache) & 8083 (websocket).

Ratchet 的官方网站上也提供了对我有用的解决方法HAProxy

The workaround does work for me is also on the official site of Ratchet HAProxy