-
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
Error: socket hang up #527
Comments
can you paste me an issue that demonstrates the problem? also are you using |
I also encounter the issue. I'm using sample code from the README: var http = require('http'),
httpProxy = require('http-proxy');
//
// Create your proxy server and set the target in the options.
//
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000);
//
// Create your target server
//
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9000); One way to reproduce is to refresh the page many times really quickly (hold down refresh keys). The 'socket hang up' error kills the process if not handled correctly. EDIT The issue appears to be caused by this line: https://github.com/nodejitsu/node-http-proxy/blob/master/lib/http-proxy/passes/web-incoming.js#L127 - It looks like Node.js always throws an error when you call req.abort(). |
@jondubois You should listen on the error event for the proxy so that you can handle the errors and return proper responses when hitting this case. It is most likely triggered because there are not anymore sockets to be used and there is no socket pooling by default. |
I noticed that when I revert back to the 0.10.x version I don't encounter this problem. It looks like 1.x.x was a fairly significant rewrite, so it's tough to say what may have changed that could be causing this issue. Perhaps someone more familiar with codebase could comment? |
@seglo in |
@jcrugzz I see, OK I'll start handling that. Are you saying that with |
@seglo in |
I feel that this error isn't very useful at all for the following reasons:
Also using an agent for socket pooling doesn't fix the issue. In my particular project (which makes use of http-proxy internally), for a while, I was just logging the error (not doing anything else) but it seemed to cause confusion among some developers who thought that it was an actual error that they needed to handle. Unlike other Node.js errors, this error appears to be completely harmless - It doesn't cause any side effects if you ignore it (I've tested this for a while) - No memory leaks. I feel that exceptions are not exceptions if they happen predictably during a common use case of the system (in this case, aborting the connection). I think it's more of a Node.js issue than an http-proxy issue - I was able to reproduce this issue in Node by creating a client request and then aborting the connection (it would throw an error whenever I called req.abort()). |
@jcrugzz Thanks for the example. I've made the appropriate updates to my project. |
@jondubois my explanation was how the |
Hi I just upgraded to version 1.7.0 of http-proxy and getting following error at random occasions. Error: socket hang up at createHangUpError (http.js:1472:15) at Socket.socketCloseListener (http.js:1522:23) at Socket.EventEmitter.emit (events.js:95:17) at TCP.close (net.js:465:12) Node.js : 0.10.28 I want to avoid these failed calls. |
Same here. Error: socket hang up
at createHangUpError (http.js:1472:15)
at Socket.socketOnEnd [as onend] (http.js:1568:23)
at Socket.g (events.js:180:16)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13) Node.js: 0.10.26 |
@ashu-daffodil can you specify what your code is doing? There was nothing in the latest release that affects how errors are handled. To me, both you and @WooDzu seem to not be handling errors when the destination you are proxying to kills the socket for whatever reason. I cannot really reason about this without a small reproducible code sample. I general, the expectation should be to get these types of errors when there are legitimate network failures or the server you are proxying to goes down. Errors need to be handled in these cases. Please see my example |
@jcrugzz REQUESTS : ERROR : Error handling CODE : var proxy = httpProxy.createProxyServer({}); |
@ashu-daffodil this is most likely a path issue, you should log the path that is trying to be requested through the proxy and debug backwards from there. This is not a bug with |
Same problem here: The cose is:
|
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
As discussed here: http-party/node-http-proxy#527
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
Why http proxy send a request to the right address, and receives 404, and if you open the same address through brouser gets json. |
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
Added the error handling to avoid http-party/node-http-proxy#527
* master: (31 commits) upgraded redux-form to v1.4.0 upgraded redux-form to 1.3.4 rolled back last commit which prematurely tried to upgrade to "history" lib added history library upgraded to v2.0.0 of redux, react-redux and redux-devtools updated redux-form to v1.2.1 upgraded to redux-form 1.0.1 upgraded to redux-form 1.0.0 Fix styles not found in production bug moved Ducks doc to its own repo for findability. fixes #146 fixed readme error to fix #151 update react-hot-loader upgraded to redux-form v0.6.1 fixed bug in previous commit. oops. undid PR #93 to fix #142. thanks, @halt-hammerzeit! added the error handling to avoid http-party/node-http-proxy#527 updated paypal button updated paypal button added paypal button updated redux-form to 0.5.0 ...
I'm getting errors that look like this happening every hour or two, causing systemd to restart my nodeProxyServer.js script:
May it be related to node-http-proxy, or something else?
The text was updated successfully, but these errors were encountered: