使用Socket.io,Node.js和iisnode保护WebSockets

时间:2016-09-19 18:58:01

标签: node.js websocket socket.io iisnode

我有一个应用程序,通过iisnode到webs.js / Express / Socket.io应用程序的websockets非常好。

  

Windows Server 2012
  iisnode 2.21
  IIS 8.5
  节点6.2.1
  socket.io 1.4.8
  express.js 4.14

然而,在通过HTTPS访问时,WebSockets在看似成功的 wss协商后回归到轮询:

GET wss://x.com/socket/a145e1f7-c8e7-4b26-96d3-a4d9869b5f3a/?id=a145e1f7-c8e7-4b26-96d3-a4d9869b5f3a&EIO=3&transport=websocket&sid=2nKT2dHWKrmO5xaHAAAM HTTP/1.1
Host: x.com
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: https://x.com
Sec-WebSocket-Version: 13
DNT: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
Cookie: io=2AAAM; _ga=GA1.2.452745265.1462472455; connect.sid=s%3M8aVwM; rl-sticky-key=!1z8WBml+V4=
Sec-WebSocket-Key: qocdK/MRQ==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Server: Microsoft-IIS/8.5
server: Microsoft-IIS/8.5
Connection: Upgrade
sec-websocket-accept: VOFznVr/l4fsY=
sec-websocket-extensions: permessage-deflate
x-powered-by: ASP.NET
X-Powered-By: ASP.NET
Date: Mon, 19 Sep 2016 18:20:04 GMT

但是这个WebSocket中没有框架,Socket.io返回HTTP轮询。如果由IIS处理TLS,那么在wss协议协商之后如何影响WebSockets?

1 个答案:

答案 0 :(得分:0)

事实证明,存在导致此问题的负载均衡器问题,技术软件堆栈没有出错。