【发布时间】:2015-01-12 01:17:01
【问题描述】:
我正在使用 Socket.io、Node.js 和 Openshift 制作多人游戏。它工作了一段时间,但我做了一些小改动,现在与我更改的内容无关的东西已经坏了。当第二个玩家尝试加入游戏时,它会将所有人都踢出去,并为其他任何进入该网站的人显示 503 错误。对于第二个玩家,我收到很多控制台错误,包括
WebSocket connection to 'ws://avalon-evao.rhcloud.com/socket.io/?EIO=3&transport=websocket&sid=d5smykffy4EWHxgIAAAC' failed: Error during WebSocket handshake: Unexpected response code: 400
http://avalon-evao.rhcloud.com/socket.io/?EIO=3&transport=polling&t=1421020862973-4&sid=d5smykffy4EWHxgIAAAC Failed to load resource: the server responded with a status of 502 (Bad Gateway)
http://avalon-evao.rhcloud.com/socket.io/?EIO=3&transport=polling&t=1421020865831-6&sid=d5smykffy4EWHxgIAAAC Failed to load resource: the server responded with a status of 503 (Service Unavailable)
socket.io-1.2.0.js:2 WebSocket connection to 'ws://avalon-evao.rhcloud.com/socket.io/?EIO=3&transport=websocket&sid=c-fwcJaMkp_9rl5CAAAA' failed: WebSocket is closed before the connection is established.
它在 localhost 中运行良好,但真实站点已损坏。
这是我尝试过的:
- 使用 HTTPS。我仍然以某种方式收到 502 错误。
- 使用
rhc app restart重新启动应用程序 - 使用
rhc app force-stop rhc app start重新启动应用程序 - 检查内存限制。我还没打。
- 使用
{ secure: true }选项安全地连接到 websockets
是什么导致了这些错误,我该如何解决?
【问题讨论】:
-
接受 websocket 连接的服务器端代码是什么样的?
标签: javascript node.js websocket socket.io openshift