Deploying Socket.io on a windows server

2019-08-07 23:34发布

问题:

I have a basic chat socket.io node.js application working on the localhost of a Windows server running Windows 7.

Node and Socket.io installed without any issue and when I run my application through RDC to the windows server, the socket works perfectly.

What I'm struggling with is how i access the socket e.g. "socket.io/socket.io.js" externally.

I would have assumed it would be rather than "localhost:8000/socket.io/socket.io.js" it owuld be "{server_ip}:8000/socket.io/socket.io.js" however this does work.

I saw some discussion about iisnode, but it seems that sockets arent supported yet with that implementation.

Any suggestions?

回答1:

You can use socket.io with iisnode, however you will not be able to use the websockets transport since IIS 7 does not support websockets. You must explicitly configure your iisnode-hosted socket.io server to use the xhr-polling transport instead.



回答2:

It turned out to be a firewall issue that was blocking access to that port which my hosting company managed to resolve for me so I'm using socket.io in the normal manner through a node command prompt.

Thanks for the advice, I did try Iisnode and like you said found that sockets weren't supported.