-
Notifications
You must be signed in to change notification settings - Fork 873
Need help. proxy webSocket - Error: read ECONNRESET #327
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
Comments
thanks for sharing your solution! |
skostic96
added a commit
to skostic96/me-and-ngrok
that referenced
this issue
Mar 16, 2025
the problem: websocket connections fail to upgrade i'm sorry i don't know which of the pages contained information about passing the proxy without route and using pathFilter option... i also provided all the relevant information in this commit because if i have spent ~20 hours, then someone else comming back to this thing doesn't have to spend as much as i did. after a lot of investigation i found that i have to setup proxy middleware as this commit specifies, i've read the following - chimurai/http-proxy-middleware#327 - https://socket.io/get-started/chat - https://stackoverflow.com/questions/66002033/socket-io-doesnt-upgrade-connection-to-websockets - chimurai/http-proxy-middleware#432 - https://socket.io/docs/v4/logging-and-debugging/ - The last section here states that net::ERR_CONNECTION_REFUSED is not an error socket.io is not emitted by socket.io. Therefore i realized that the problem is elsewhere and that request is being passed through proxy to socket.io fine. I checked in public/app.js on server.on('upgrade', ...); that event is being passed through to the api, and it was being passed through to the api, as the api has received the event/request. I did something like: server.on('upgrade', (req, socket, head) => { // append unique id to req headers // log upgrade and request being proxied wsProxy.upgrade(req, socket, head); }); And I had found out that request is being handled by socket.io but the proxy has been logging an error. I haven't found out the cause of the problem. However after ~20 hours of searching, this was the major clue that made me realize the only problem was a line in my code. And randomly i remembered reading that providing proxy as middleware without path in app.use() solved problem for some people. - https://www.npmjs.com/package/http-proxy-middleware#pathfilter-string-string-glob-glob-function - And I've read the rest of the sections, especially the ones related to websockets. - chimurai/http-proxy-middleware#204 - chimurai/http-proxy-middleware#432
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Is this a question?
Using HPM to proxy webSocket. But once webSocket server shut down, HPM server will catch this error and crash.
The root cause seem to be an error event has not been handled. But I dont know where to handle it.
Env
Node: 10.8.0
HPM: 0.19.0
System: Mac OS 10.13.6
Error logs & config
events.js:167
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onread (net.js:660:25)
Emitted 'error' event at:
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
Is this a bug report?
(write your answer here)
Is this a feature request?
(write your answer here)
Steps to reproduce
(Write your steps here:)
Expected behavior
(Write what you thought would happen.)
Actual behavior
(Write what happened.)
Setup
client info
target server info
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
The text was updated successfully, but these errors were encountered: