-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make WebSocket work with proxy settings? #8416
Comments
I have similar issue, this middleware works weird, it is somehow trying to proxy websocket sockjs-node request from webpackDevServer to my api server and I have these errors
So if I have two WS connections and one of them has proxy then webpack also proxy his sockjs-node to that server, but it shouldn't do this. UPDATE: I figured out how it actually works for me without proxying WebpackDevServer sockjs-node.
We need first
And we need second Now it works like a charm. Hope it helps someone. :) |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Still having the issue, did someone found a solution? |
@apiel did you check my answer above? |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue. |
I try to proxy my websocket in dev mode using the manual proxy as described in the documentation https://create-react-app.dev/docs/proxying-api-requests-in-development/#configuring-the-proxy-manually
In my
src/setupProxy.js
I have the following code:But when I try to connect, the connection get disconnected directly:
When you look at the documentation of http-proxy-middleware they requiere
server.on('upgrade', wsProxy.upgrade);
, see https://github.com/chimurai/http-proxy-middleware#external-websocket-upgradeOr the http
server
is not available in setupProxy.jsDid someone already manage to proxy websocket with create-react-app?
Edit
After debugguing the code for hours, I get the following error from http-proxy:
It seem that
server.on('upgrade', wsProxy.upgrade);
is done byhttp-proxy-middleware
inside the middleware withreq.connection.server
. But I wonder if thisserver
is the one expected byhttp-proxy
. When I try to instanciate my own websocket server I get some similar STREAM issue:With this code I get the following error:
The text was updated successfully, but these errors were encountered: