Skip to content

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

@cupuyc

Description

@cupuyc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions