我设法使 websocket 在 azure 上的 nodeJS+express 应用程序上工作。
但是它使用轮询而不是 websocket,有人知道为什么吗?
这是配置。
客户端
socket = io.connect(url, {'transsports':['websocket', 'polling']);
服务器端
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
console.info('Express server started');
});
var io = require('socket.io').listen(server, {'transports': ['websocket', 'polling']});
我使用的是socket.io 1.3.6
编辑:
在 Azure 上,我有 websocket 且“始终在线”设置为“开”。
它也不是免费的软件包。
最佳答案
好的。我还有一个托管在 azure 网站上的 socketIO 应用程序,并且网络套接字确实按预期工作。你检查过这篇文章吗? Enabling Websockets for Socket.io Node apps on Microsoft Azure
这是重要的部分:
Note that we say "webSocket enabled=false" in this web.config. This is confusing, but makes sense when you realize we're saying "disable Websockets in IIS and let node (or whomever) downstream handle it"
关于node.js - Azure 上使用 NodeJS 的 Websocket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32227247/