Websockets出现400、502、503错误 [英] 400, 502, 503 errors with Websockets
问题描述
我正在使用Socket.io,Node.js和Openshift制作多人游戏.它工作了一段时间,但我做了一些小改动,但现在与我所做的更改无关的东西坏了.当第二位玩家尝试加入游戏时,它将引导所有人退出,对网站上的其他任何人都显示503错误.对于第二个玩家,我遇到了很多控制台错误,包括
I am making a multiplayer game using Socket.io, Node.js, and Openshift. It was working for a while, but I made a few small changes and now something unrelated to what I changed has broken. When a second player tries to join the game, it boots everyone out, showing a 503 error for anyone else who goes on the site. For the second player, I get a lot of console errors including
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上运行正常,但实际站点已损坏.
It works perfectly fine in localhost, but the real site is broken.
这是我尝试过的:
- 使用HTTPS.我仍然仍然会收到502错误.
- 使用
rhc app restart
重新启动应用
- 使用
rhc app force-stop rhc app start
重新启动应用
- 检查内存限制.我还没打.
- 使用
{ secure: true }
选项安全地连接到Websocket
- Using HTTPS. I still somehow get the 502 error.
- Restarting the app using
rhc app restart
- Restarting the app using
rhc app force-stop rhc app start
- Checking the memory limit. I haven't hit it.
- Connecting to websockets securely using the
{ secure: true }
option
是什么原因导致这些错误,我该如何解决?
What is causing these errors and how can I fix them?
推荐答案
尝试:
ws://...rhcloud.com:8000/socket.io/...
wss://...rhcloud.com:8443/socket.io/...
Try:
ws://...rhcloud.com:8000/socket.io/...
wss://...rhcloud.com:8443/socket.io/...
这篇关于Websockets出现400、502、503错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!