nodejs socket.io 与 IIS 节点
我已经在 Windows Vista/IIS 7 中使用 iis 节点尝试了使用 node.js 进行一些操作。我的想法是在 asp .net mvc 应用程序上使用服务器脚本连接到另一个套接字服务器并以持久方式服务请求。
我在 https://github.com/tjanczuk/iisnode 下载了适用于 IIS 7 的 iisnode 版本,并且能够使用 web.config 和 IIS 模块配置中的 http 处理程序映射运行基本的“hello world”http 服务器管道。
我正在尝试使用node.js 中的socket.io 库。如果我编写服务器和客户端,这将独立工作。但与 IIS 节点一起使用时失败。
我在进一步下降时遇到问题。诸如
- 如何在 asp .net mvc 项目中包含 npm 模块?我试过 将node_modules放在节点脚本的文件夹中,但这确实 没有帮助。基本上 require('socket.io') 命令可以工作,但是 套接字连接等,根本就失败了。
- 如何拥有一个套接字 来自客户端的连接,它将继续侦听来自的更新 服务器(如 COMET) - 正如我所说,我正在尝试使用 socket.io
之前有人尝试过吗?
I have tried something with node.js in windows vista/IIS 7 using iis node. My idea is to use a server script on the asp .net mvc application to connect to another socket server and serve requests on a persistent fashion.
I downloaded the iisnode version at https://github.com/tjanczuk/iisnode for IIS 7 and able to run the basic 'hello world' http server pipe using http handler mappings in web.config and IIS modules configuration.
I am trying to use socket.io library from node.js. This works independently if I write a server and client. But fails when used with IIS node.
I am having problems going down further. Problems like
- How to include the npm modules in the asp .net mvc project? I tried
putting the node_modules in the folder of node scripts, but that did
not help. Basically the require('socket.io') command works, but the
socket connection etc., simply fails. - How to have a socket
connection from client which will keep listening for updates from
server(like COMET) - As I said I am trying to use socket.io
Any body tried this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
回读几个月前,IIS下的Socket.IO不支持WebSocket支持,无论轮询有多长。
这是几个月前的事,我现在遇到了同样的问题并试图解决。
正如托马斯写道:
看起来截至2012年2月23日,该功能仍不支持。
需要通过IIS吗?您是否可以选择使用纯 Socket.IO/Node 选项来消除 IISNode?如果您需要具有后备功能的完整 WebSocket 支持,这看起来是唯一的选择,除非有其他建议?
Reading back a few months ago, WebSocket support is not supported with Socket.IO under IIS, however long polling is.
This was a few months ago, and I'm running up against the same issue now and trying to resolve.
As Tomasz writes:
By the looks of it, as of Feb 23, 2012, this functionality is still not supported.
Do you need to go through IIS? Do you have the option of going with a pure Socket.IO/Node option, eliminating IISNode? If you need full WebSocket support with fallback capability, this looks like the only option, unless there are other suggestions?
这可能与您的问题有关,也可能无关。我没有对 socket.io 做太多事情,但是我计划做一些与您所描述的非常相似的事情。在阅读 iisnode 的源代码时,我在 cnodehttpmodule.cpp 中发现了以下代码:
在我看来,如果“websocket”包含在请求的标头中,它将被拒绝。我需要阅读 websocket 协议才能更好地理解这意味着什么。
我将是第一个承认我不太了解 Websocket 与长时间运行的请求有何不同的人。然而,据我了解,socket.io 将在不支持 websocket 的旧浏览器上运行。
我建议您尝试将传输设置为 xhr-polling 或 jsonp-polling。它有点打败了使用 Node.js 的酷炫因素,但它可能会帮助您解决问题。
This may or may not be related to your problem. I haven't done much with socket.io, however I was planing to do something very similar to what you're describing. When reading through the source for iisnode, I found the following code in cnodehttpmodule.cpp:
It looks to me as though if "websocket" is included in the header of the request, it will be rejected. I would need to read up on the websocket protocol to better understand exactly what this means.
I'll be the first to admit that I don't know overly well how websockets differ from a long running request. As I understand it, however, socket.io will work on older browsers that do not support websockets.
I recommend you try to set the transport to just xhr-polling or jsonp-polling. It kinda defeats the cool factor of using node.js but it might help you reach a resolution to your problem.
如果您的 socket.io Web 应用程序托管在 IIS 虚拟目录中,则与自托管情况相比,必须修改 socket.io 配置。请参阅 http://tomasz.janczuk.org /2013/01/hosting-socketio-websocket-apps-in-iis.html 了解详细信息。
此外,从版本 0.2.x 开始,iisnode 确实支持 Windows 8 和带有 IIS 8 的 Windows Server 2012 上的 WebSocket。查看 http://tomasz.janczuk.org/2012/11/how-to-use-websockets-with-nodejs-apps.html 了解详细信息。
If your socket.io web application is hosted in an IIS virtual directory, socket.io configuration must be modified compared to a self-hosted case. Please see http://tomasz.janczuk.org/2013/01/hosting-socketio-websocket-apps-in-iis.html for details.
Also, as of version 0.2.x, iisnode does support WebSockets on Windows 8 and Windows Server 2012 with IIS 8. Check out http://tomasz.janczuk.org/2012/11/how-to-use-websockets-with-nodejs-apps.html for details.