-
Notifications
You must be signed in to change notification settings - Fork 825
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
EventSource not working #35
Comments
@jmls Could you provide a sample setup showing this issue? Debugging it will be much faster. Did you tried your setup with |
Don't think this is a http-proxy-middleware issue. Feel free to re-open this issue if you think it is a bug. |
Just out of curiosity: Is there any way to set the keep alive timeout for proxy within webpack config? Is there any flag I can set to avoid a SSE keep-alive-related disconnect?
|
I never used SSE... But you can try to configure a custom You'll something like this: const http = require('http');
var keepAliveAgent = new http.Agent({ keepAlive: true });
devServer: {
proxy: {
'/api/*': {
target: 'XYZ',
secure: false,
changeOrigin: true,
agent: keepAliveAgent
},[...] |
any example for SSE ? |
@chimurai Why is this closed? SSE is definitely not working over http-proxy-middleware. Also every time the connection times out node logs out this message: I can setup an example repo if needed, to demonstrate that messages are not arriving to the client |
Has anyone made progress using eventSource requests through httlp-proxy-middleware? For my tests, the request works, but reconnection fails, even with the agent set as above. |
Same problem. |
Here is an issue #371 in which A dozen of (mis)configuration can lead to a non-working setup. |
Verified proxying SSE is working with: const app = express();
app.use(createProxyMiddleware({
target: 'http://express-eventsource.herokuapp.com',
changeOrigin: true,
}));
app.listen(3000); |
@chimurai I've verified that it works when you disable compression, but what it does not do is close the connection to the server when the client disconnects from an EventStream. I've tried it both with just closing the browser window and with cleaning up with |
I'm using http-proxy-middleware in a React environment and I found out that the problem wasn't really with http-proxy-middleware, but somehow with how react is handling proxying by default with setupProxy.js. const express = require('express')
const app = express()
const { createProxyMiddleware } = require('http-proxy-middleware')
app.use(
'/api',
createProxyMiddleware({
secure: true,
changeOrigin: true,
target: 'http://your-api-url'
})
)
const wsProxy = createProxyMiddleware({
changeOrigin: true,
target: 'http://localhost:3000',
ws: true
})
app.use('/sockjs-node', wsProxy)
app.use(
'/',
createProxyMiddleware({
changeOrigin: true,
target: 'http://localhost:3000'
})
)
const server = app.listen(3001)
server.on('upgrade', wsProxy.upgrade) |
I don't know if this is a http-proxy-middleware problem or a browser-sync problem (reported there as well BrowserSync/browser-sync#872) but I can't get EventSource to work when using this combination.
I am trying to use EventSource from my node-js app and push events to the client -
Has anyone managed to get this working ? I have no errors, no messages on the console but also no events. :(
If I run an example app just using node, things work fine so I know it's a problem with the combination of browser-sync and http-proxy-middleware
thanks
The text was updated successfully, but these errors were encountered: