-
Notifications
You must be signed in to change notification settings - Fork 2k
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
chain proxy in case of error #123
Comments
Are you buffering the request? You need to be doing buffering because you will need to re-emit the Can you provide a code sample? I can probably help you quickly; if you're not familiar with event buffering it can be tricky to get right. |
I haven't the code with me and my implementation is pretty naive with no buffering, just chaining 2 RoutingProxy (tried also with RoutingProxy + create a HttpProxy in case of error). I'm not familiar with event buffering yet (or maybe; but I didn't know it is called like this), so I'll just post here an example tomorrow (it's >2:00am here) and hope for help ;) |
I'm also looking into getting this working, would buffering the request cause significant performance issues? Charlie, If you have some pointers on where to start re the event buffering that would be great. |
Hi, I'm trying to do something like this:
while this works for the 1st fe hundred requests, after about 300 or so I see a whole bunch of these errors: response.resume error: Cannot resume() closed Socket. Clearly I'm doing something wrong. I wonder if it would be a nice feature to have proxyRequest accept multiple backends to try.
or something along those lines? So to get back to my problem, what is the correct way to go about achieving this desired "failover"?. Bearn. |
any suggestions on this? |
@bearnard I'm not sure there is a workable solution here. The Consider the scenario when the first backend fails midway through the response. It is impossible for the proxy to know at what point of the response the reverse proxy request errored. My suggestion would be to pass a mock response object to |
This should be fixed by #374 since the |
Is there any workaround for this problem after 2 years? |
Something I try to do with node-http-proxy for some days now, is chaining proxies in case of error : I have multiple middle server. During a delivery, at least one server will be down for a while, so I'd like, if I get an ECONNREFUSED (or a hangup, but it happens for now in about 240s, I guess 2x 120s timeout, and I didn't get how to change this), I'd like my proxy to try another host instead of returning an error I could avoid<
I've created a first proxy, I listen to the "proxyError" event, which is fired, then I ask a second proxy to handle that request and try another equivalent host), it tries to handle the request then I have a "start" event as well for it, but it never writes to my response. My response is writable because I can write to it then call res.end().
I didn't get why for now. Is it possible to do?
The text was updated successfully, but these errors were encountered: