Manually upgrading upgrade requests to socket.io socket? #4068
Answered
by
darrachequesne
Blakeinstein
asked this question in
Q&A
-
I am trying to manually handle the socket upgrade request, so that I can proxy to another port on subdomains, and go to socket.io otherwise. Trying to use http2-proxy, but I cant find documentation on how to upgrade to socket.io socket server.on('upgrade', (req, socket, head) => {
if (req.headers.host ...)
return proxy.ws(req, socket, head, { target ... });
io.????? // upgrade to socket.io here
} I also tried io.use((socket, next) => {
if (socket.request.headers.host ...)
return ??? // Proxy to target port here
next();
} And I am confused as to what I should do to proxy socket.io socket |
Beta Was this translation helpful? Give feedback.
Answered by
darrachequesne
Sep 1, 2021
Replies: 1 comment 3 replies
-
You can manually upgrade with Please see the documentation here: https://socket.io/docs/v4/server-api/#engine-handleUpgrade-request-socket-head |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Blakeinstein
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can manually upgrade with
io.engine.handleUpgrade()
.Please see the documentation here: https://socket.io/docs/v4/server-api/#engine-handleUpgrade-request-socket-head