反向代理和Socket.io,失败的WebSocket握手

问题描述 投票:1回答:1

我运行Windows Server 2008 R2上使用IIS 7.5的一个小网站。我有一个Node.js应用程式过于端口3000上运行。

HTTP从网站(客户端浏览器)调用的反向代理从http://example.com/node/whateverhttp://localhost:3000/whatever。一切工作正常为止。

问题是,当我尝试使用socket.io。

我收到:

    WebSocket connection to 'ws://example.com/socket.io/?EIO=3&transport=websocket&sid=adb9WRpoMFYRoS0vAAAB' 
failed: Error during WebSocket handshake: Unexpected response code: 502 

我敢肯定,如果我没有错,认为:

它转发到我的服务器的初始请求作为到WebSocket服务器的初始请求是标准的HTTP请求(具有一些额外的标头)。 IIS不知道这件事,只是转发请求。然而,在接收到的WebSocket请求网页套接字服务器发送一个响应101和切换到的WebSocket模式。 IIS不理解WebSocket的流量,它是不能代理这一点。

有没有什么窍门或解决方案以配置WS反向代理://不会忽略?

node.js sockets socket.io iis-7.5 reverse-proxy
1个回答
0
投票

我会扩大我的意见了一下。据我了解,你有几种选择:

所以,这socket.io的版本,您使用的?参见允许传输(下面提取)的docs

io.enable('browser client minification');  // send minified client
io.enable('browser client etag');          // apply etag caching logic based on version number
io.enable('browser client gzip');          // gzip the file
io.set('log level', 1);                    // reduce logging

// enable all transports (optional if you want flashsocket support, please note that some hosting
// providers do not allow you to create servers that listen on a port different than 80 or their
// default port)
io.set('transports', [
    'websocket'
  , 'flashsocket'
  , 'htmlfile'
  , 'xhr-polling'
  , 'jsonp-polling'
]);
© www.soinside.com 2019 - 2024. All rights reserved.