How can I setup a reverse proxy to work with botpress socketio to resolve: Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value

Matt Pavlik 1 Reputation point
2022-07-09T05:42:43.14+00:00

I've setup a reverse proxy using IIS:

"A" external url is "https://A.com"
"B" local/private URL is "HTTP://localhost:3000"
"C" is the user website ("A" is a subdomain of "C") "https://www.C.com"

The user browses to C. C has an embedded botpress chat window that references A. IIS translates A into B to access the botpress server on my windows 2022 VPS.

I know the botpress server is working, because I can connect to it fine from a non HTTPS website "D" (if I bypass the proxy and connect using HTTP).

But when it connects to complete the handshake, it returns Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value, along with Firefox can’t establish a connection to the server at wss://A.com/socket.io/?visitorId=Eldl1x5hrvQeeBO8teFxm8g8&EIO=4&transport=websocket.

Here is the header info:

GET wss://A.com/socket.io/?visitorId=Eldl1x5hrvQeeBO8teFxm8g8&EIO=4&transport=websocket
[HTTP/1.1 101 Switching Protocols 191ms]

GET
wss://A.com/socket.io/?visitorId=Eldl1x5hrvQeeBO8teFxm8g8&EIO=4&transport=websocket
Status
101
Switching Protocols
VersionHTTP/1.1
Transferred241 B (0 B size)

Content-Security-Policy    frame-ancestors *;  
Date  
 Sat, 09 Jul 2022 05:09:29 GMT  
Sec-WebSocket-Accept  
 orGxow4u6jRPNkiRBDlXZdo86/U=  
Transfer-Encoding  
 chunked  
Upgrade  
 websocket  
X-Powered-By  
 ARR/3.0  
  
Accept  
 */*  
Accept-Encoding  
 gzip, deflate, br  
Accept-Language  
 en-US,en;q=0.5  
Cache-Control  
 no-cache  
Connection  
 keep-alive, Upgrade  
Cookie  
 _ga=GA1.2.390039939.1641657789; _ga=GA1.3.390039939.1641657789; _gid=GA1.3.1224013694.1657119697; _ga_RC9DH6WTNR=GS1.1.1657249666.3.0.1657249666.0; _gid=GA1.2.697700950.1657340575; _gat=1  
Host  
 A.com  
Origin  
 https://A.com  
Pragma  
 no-cache  
Sec-Fetch-Dest  
 websocket  
Sec-Fetch-Mode  
 websocket  
Sec-Fetch-Site  
 same-origin  
Sec-WebSocket-Extensions  
 permessage-deflate  
Sec-WebSocket-Key  
 uDFXNhsUO546R3/x1pjQ+w==  
Sec-WebSocket-Version  
 13  
Upgrade  
 websocket  
User-Agent  
 Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0  

What am I missing?

Windows development | Internet Information Services
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.