socket.io creating 502 Bad Gateway on connect / websocket invalid

走远了吗. 提交于 2020-01-15 08:16:52

问题


I'm trying to get a simple socket.io server running:

Client:

<script src="http://www.my-server.com:8080/socket.io/socket.io.js"></script>
var socket = io.connect("http://www.my-server.com:8080/");

The socket script is being served correctly. When the client connects, a

NetworkError: 502 Bad Gateway : http://www.my-server.com:8080/socket.io/1/websocket/20667461671864648294

occurs and the server prints:

warn - websocket connection invalid

I can't really find my problem. if it's a serverside/node problem, the socket.io.js script shouldn't be available, right?

What am i doing wrong?


回答1:


Got it.

I am using a CDN between user and server. After disabling boost/cache for my socket domain, the errors were gone and the socket became valid.

Should have thought of this earlier!




回答2:


Serving the socket.io file works fine because it's HTTP. Are you using a web server in front of node.js that doesn't allow web sockets (like IIS web roles or Win Azure); or are web socket connections disabled in the firewall of the server?



来源:https://stackoverflow.com/questions/9908297/socket-io-creating-502-bad-gateway-on-connect-websocket-invalid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!