-
Notifications
You must be signed in to change notification settings - Fork 852
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
SSE close events do not make it through proxy running on Windows #678
Comments
It seems to be a problem with the http-proxy module (which is used by http-proxy-middleware), since I had the same problem trying to proxy SSE connections through it. According to this issue that i found in their repository, it can be fixed this way: const express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
const app = express();
app.use('/', createProxyMiddleware({
target: 'http://localhost:3002/',
changeOrigin: true,
onProxyReq: (proxyRes, req, res) => {
res.on('close', () => proxyRes.destroy());
}
}));
app.listen(3003); |
I'm having perhaps the inverse of this. When my backend server doing SSE dies, the proxy neither reconnects, nor disconnects the client so it can try to reconnect. |
@gitpushdashf I am currently having the exact same problem. Did you find a way of solving this? |
This also solved my similar issue where I was streaming a mjpeg stream from my API and the backend relies on a close event to clean up certain connections. without this the API would never receive a close callback |
THANKS - This fixed my issue as well. I am seeing it on MacOS so not a Windows issue. MacBook Pro - Model Identifier: Mac14,7 with M2 chip running on macOS 14.4.1 (23E224) The problem only happens for me when using |
Should it be target: 'http://localhost:3002/',
changeOrigin: true,
on: {
proxyReq: (proxyRes, req, res) => {
res.on("close", () => proxyRes.destroy());
},
}, or target: 'http://localhost:3002/',
changeOrigin: true,
onProxyReq: (proxyRes, req, res) => {
res.on('close', () => proxyRes.destroy());
} ? |
yarn why http-proxy-middleware
ORnpm ls http-proxy-middleware
output (mask private folder names with *****)http-proxy-middleware
.Describe the bug (be clear and concise)
When proxy is run on Windows, although data passes to the client, the server doesn't receive any SSE "closed" events until the proxy itself is stopped.
Here is the minimal proxy I am running:
I have a SSE server running on 3002, I connect to it on 3003 (via the proxy)
Step-by-step reproduction instructions
Expected behavior (be clear and concise)
The server should register the SSE "close" event
What http-proxy-middleware configuration are you using?
What OS/version and node/version are you seeing the problem?
Additional context (optional)
Works inside WSL, does not work from Powershell or CMD
The text was updated successfully, but these errors were encountered: