Error handling on proxy error
See original GitHub issueWhat is the graceful way to handle proxy errors? Currently what happens if the server that should be proxied to fails, is that the application crashes with a:
.../node_modules/http-server/node_modules/http-proxy/lib/http-proxy/index.js:119
throw err;
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
The proxy object is not available. So I can not add an error handler. Something like the following would be very usefull:
if (typeof options.proxy === 'string') {
var proxy = httpProxy.createProxyServer({});
before.push(function (req, res) {
proxy.web(req, res, {
target: options.proxy,
changeOrigin: true
});
});
// NEW CODE HERE
if (options.proxyErrorHandler) {
proxy.on('error', options.proxyErrorHandler);
}
// END NEW CODE HERE
}
This is just an idea. But custom handling of errors in the proxy would be more useful to me, then an exception. 😃
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
How to Solve Proxy Error Codes - The Ultimate Guide! - NetNut
A proxy error is an HTTP error status that you will receive as a response when a request sent to the web server...
Read more >Proxy Services: Error Handlers - Oracle Help Center
Since an error handler is another pipeline, it is configured like any other pipeline. For example, the Publish action may be used to...
Read more >How to Solve Proxy Error Codes - Infatica
Errors make scraping unbearably difficult or even impossible to execute. In this article, we will take a look at all HTTP error codes...
Read more >Proxy error handling · Issue #138 · microsoft/reverse ... - GitHub
Describe the bug. The proxy should catch exceptions from the HttpProxy and convert them to 503s or other statuses as appropriate.
Read more >Error Handling via Try & Catch Proxy in Javascript - Medium
1.First, we define proxy function that takes an argument, which is the class that we are going to wrap its methods. · 2....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also met this error when my target server was starting and not yet ready to be used.
When ECONNREFUSED happens, instead of killing the http-server process, it is possible to simply return “503 Service Unavailable” to the client, keeping the http-server service alive?
Or at least, can be helpful to provide an option to disable this default behavior (exit process), returning 503 http code instead.
+1 ! a switch on cli command too !