-
Notifications
You must be signed in to change notification settings - Fork 848
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
Server crashed with thousands of [HPM] Upgrading to WebSocket attempts #733
Comments
@hossein-zare I am getting the same issue. Do you know how to fix this? |
@VladislavMurashchenko I used http-proxy: const require('http-proxy');
const app = express();
const server = http.createServer(app);
const proxy = httpProxy.createProxyServer({
target: {
host: 'example.com',
port: 4001
}
});
server.on('upgrade', (req, socket, head) => {
const domain = req.headers.host;
const host = domain.split(':')[0];
if (host === 'socket.example.com') {
proxy.ws(req, socket, head);
} else {
socket.destroy();
}
}); |
Can you try with It contains a fix for server crashes from websocket errors |
Think the filter option is what you were looking for: // only proxy on this condition:
const filter = (path, req) => {
const domain = req.headers.host;
const host = domain.split(':')[0];
return host === 'socket.example.com'
}
const conf = {
target: `http://mydomain.com:4000`,
changeOrigin: true,
ws: true,
router: {
'socket.mydomain.com:4000': `http://mydomain.com:4001`,
}
};
const wsProxy = createProxyMiddleware(filter, conf); |
still broken |
@chimurai node-http-proxy socket will throw error if no error listener for default eventemitter
|
how to: just this.proxy.ws(req, socket, head, activeProxyOptions, this.logError); |
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Checks
http-proxy-middleware
.Describe the bug (be clear and concise)
I want to proxy
socket.mydomain.com:4000
to a websocket server running atmydomain.com:4001
.it's working fine but If i change
socket.domain.com
toapp.domain.com
the server tries to upgrade to websocket then craches.Log
Step-by-step reproduction instructions
Expected behavior (be clear and concise)
The server must not crash if the client tries to connect to another subdomain.
How is http-proxy-middleware used in your project?
What http-proxy-middleware configuration are you using?
What OS/version and node/version are you seeing the problem?
Additional context (optional)
No response
The text was updated successfully, but these errors were encountered: