我在 azure 上部署了一个 socket.io v0.9.17 节点 js 应用程序(我已经在本地使用两个客户端进行了测试,它工作正常),代码如下:
var util = require("util");
var port = process.env.PORT || 1337;
var app = require("http").createServer(function (req, res) {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Socket.io application");
}).listen(port);
var io = require('socket.io').listen(app);
io.configure(function () {
io.set("transports", ["websocket"]);
});
io.sockets.on('connection', function (client) { ... }
我尝试通过 socket.io-java-client 连接到它:
// Have tested with different ports
socket.connect("http://myapp.azurewebsites.net:1337/", this);
这给了我客户端错误:
Error while handshaking... Operation timed out
服务器上的日志:
debug: websocket writing 1::
debug: setting request GET /socket.io/1/websocket/SFePun_Ug5ycS5EVIrSO
debug: set heartbeat interval for client SFePun_Ug5ycS5EVIrSO
debug: discarding transport
debug: cleared heartbeat interval for client SFePun_Ug5ycS5EVIrSO
debug: setting request GET /socket.io/1/websocket/SFePun_Ug5ycS5EVIrSO
debug: set heartbeat interval for client SFePun_Ug5ycS5EVIrSO
debug: discarding transport
debug: cleared heartbeat interval for client SFePun_Ug5ycS5EVIrSO
debug: setting request GET /socket.io/1/websocket/SFePun_Ug5ycS5EVIrSO
debug: set heartbeat interval for client SFePun_Ug5ycS5EVIrSO
debug: discarding transport
(repeated a couple of times)
...
IIS Detailed Error - 503.13 - Number of active WebSocket requests has reached the maximum concurrent WebSocket requests allowed.
socket.connect("http://myapp.azurewebsites.net/", this);
如果我连接一个客户端,这不应该发生。
任何想法如何解决这一问题?
编辑:试图从传输 websocket 更改为 xhr-polling。这不会给我 HTTP 503.13 错误并建立与服务器的连接,但效果不佳。