http-proxy-middleware icon indicating copy to clipboard operation
http-proxy-middleware copied to clipboard

What is proper way to terminate WebSocket proxy. We use `socket.end()`

Open cupuyc opened this issue 1 year ago • 0 comments
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

cupuyc avatar Oct 23 '24 16:10 cupuyc