当用户打开http://sync.aws.af.cm/时,Google Chrome JavaScript控制台会显示(几秒钟内):
Unexpected response code: 502 error
Run Code Online (Sandbox Code Playgroud)
即使用户刷新页面,应用程序也应该记住文本区域的内容.该应用程序在本地工作,但不是当我上传到AppFog时,我怀疑问题是502错误.
你知道在这种情况下会导致这个错误的原因吗?
我试图改变script src=<path_to_socket_io>
从我的客户端的路径/socket.io/socket.io.js
来node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js
描述这里,但它并没有帮助.
我也尝试在Heroku而不是AppFog上提供应用程序,但在这种情况下,即使我指定了socket.io版本0.9.6 ,我仍然遇到此处描述的问题.
我也看过以下问题,但到目前为止的评论似乎对我没有帮助.
socket.io在connect/websocket上创建502 Bad Gateway无效
Socket.IO node.js websocket连接无效端口8081
这是相关的服务器代码:
var server = http.createServer(function (req, res) {
...
});
var io = require('socket.io').listen(server);
// Define events that can be triggered by the client
io.sockets.on('connection', function (socket) {
socket.on('setServerVariable', function (value) {
...
});
...
});
server.listen(process.env.VCAPP_APP_PORT || 3000);
Run Code Online (Sandbox Code Playgroud)
<script …
Run Code Online (Sandbox Code Playgroud)