http-proxy-middleware
http-proxy-middleware copied to clipboard
What is proper way to terminate WebSocket proxy. We use `socket.end()`
trafficstars
Describe the feature you'd love to see
We use socket.end() to terminate websocket proxy. Is it correct way? There is no docs for that. We suspect it causes memory leak.
We use next config to add extra auth to some target websocket server.
const proxy = createProxyMiddleware({
target: "ws://our.target.ws.com",
changeOrigin: true,
ws: true,
on: {
error: err => {
console.log('WARN: http proxy error', err);
},
proxyReqWs: (proxyReq, req, socket) => {
// some auth logic
if (!auth) {
socket.end();
}
},
},
});
Additional context (optional)
No response