403禁止使用socket.io和iisnode

时间:2014-06-15 10:36:46

标签: node.js iis https socket.io iisnode

我有一个node.js socket.io服务器应用程序,我刚刚移动到Windows Server 2012中的IIS 8.5中的IISNode。它设置为使用https。

当我在本地浏览但当我尝试使用完整域名访问它时,一切正常,当我尝试打开W​​eb套接字连接时,我收到错误403(禁止)。

与Dante Devine Comedy socket.io示例一样,我的实际应用程序也会出现同样的问题。 Tomasz Janczuk iisnode Dante sample

使用

浏览时的标准样本
https://localhost/dante/server-socketio.js

https://interfaces.xxxxxx.co.uk/enable/testing/dante/server-socketio.js

在同一服务器上本地打开与

的socket.io Web套接字连接
var client = io.connect('https://localhost', { resource: 'dante/socket.io' });

并正确生成以下网络捕获:

Working network capture

显然,当从外部访问(而不是localhost)时,上述操作无效,因此我将Web套接字连接更改为

var client = io.connect('https://interfaces.xxxxxx.co.uk/enable/testing', 
              { resource: 'dante/socket.io' });

并且失败,错误403如下:

enter image description here

我的web.config与Dante示例提供的相同,包含:

<handlers>
  <add name="iisnode-socketio" path="server-socketio.js" verb="*" modules="iisnode" />
</handlers>

<rewrite>
     <rules>
          <rule name="LogFile" patternSyntax="ECMAScript">
               <match url="socket.io"/>
               <action type="Rewrite" url="server-socketio.js"/>
          </rule>
     </rules>
</rewrite>    

<webSocket enabled="false" />

我是node.js,socket.io和iisnode的新手以及IIS的新手,所以这可能是一个简单的iis / web站点/ https问题,与iisnode无关。

如果有人有任何建议,我会很感激。

约翰。


按照CuriousGuy的建议,我现在得到以下网络捕获,显示没有发生切换到Web套接字协议。显示的实际错误是

WebSocket connection to 'wss://interfaces.xxxxxx.co.uk/enable/testing/dante/socket.io/1/websocket/ANNcSf7ghQp66nwSS-7P' 
failed: Error during WebSocket handshake: Unexpected response code: 200 

No longer gives 403 error

我尝试从

更改服务器io.set
io.set('resource', '/dante/socket.io');

io.set('resource', '/enable/testing/dante/socket.io');

但这显然是一个错误,因为我得到一个错误,即io未定义,这似乎有点奇怪。

如果我在fiddler中检查网络流量,我会看到:

output from fiddler

当我点击最后一个网络线时,

以及fiddler中的以下错误消息:

iisnode在处理请求时遇到错误。

HRESULT: 0x6d
HTTP status: 500
HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because
system.webServer/iisnode/@devErrorsEnabled 
configuration setting is 'true'.

服务器stderr日志显示:

debug: served static content /socket.io.js
debug: client authorized
info: handshake authorized o7WE52TfMWPxFoJIZFJJ
debug: setting request GET /dante/socket.io/1/websocket/o7WE52TfMWPxFoJIZFJJ
debug: set heartbeat interval for client o7WE52TfMWPxFoJIZFJJ
warn: websocket connection invalid
info: transport end (undefined)
debug: set close timeout for client o7WE52TfMWPxFoJIZFJJ
debug: cleared close timeout for client o7WE52TfMWPxFoJIZFJJ
debug: cleared heartbeat interval for client o7WE52TfMWPxFoJIZFJJ

0 个答案:

没有答案