简体   繁体   English

使用NodeJS在Azure上使用Websocket

[英]Websocket on Azure with nodeJS

I manage to make websocket work on a nodeJS+express application on azure. 我设法使websocket在azure上的nodeJS + express应用程序上工作。
However it is using polling instead of websocket, anyone know why is that? 但是它使用轮询而不是websocket,有人知道为什么吗?
Here are the config. 这是配置。

Client Side 客户端

socket = io.connect(url, {'transports':['websocket', 'polling']);

Server side 服务器端

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']});

I am using socket.io 1.3.6 我正在使用socket.io 1.3.6

EDIT: 编辑:

On Azure I have websocket and the Always On setting ON. 在Azure上,我有websocket,并且Always On设置为ON。
It's also not a the free package. 这也不是免费的软件包。

OK. 好。 I also have a socketIO app hosted on an azure website, and the web sockets does work as expected. 我还在azure网站上托管了一个socketIO应用程序,并且Web套接字确实可以正常工作。 Did you check this article out? 您是否检查了这篇文章? Enabling Websockets for Socket.io Node apps on Microsoft Azure 在Microsoft Azure上为Socket.io节点应用程序启用Websockets

Here's the important part: 这是重要的部分:

Note that we say "webSocket enabled=false" in this web.config. 请注意,我们在此web.config中说“ webSocket enabled = false”。 This is confusing, but makes sense when you realize we're saying "disable Websockets in IIS and let node (or whomever) downstream handle it" 这令人困惑,但是当您意识到我们在说“禁用IIS中的Websocket并让下游的节点(或任何人)处理”时,这是有道理的。

我最终将socket.io降级到1.3.5,以使Websockets在Azure(iisnode)上工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM