3

I try to download and parse some big xml files. The files are from some affiliates sites that don't have a proper API right now. I use the request module for nodejs but I allways get the same error.

Error: read ECONNRESET
at exports._errnoException (util.js:746:11)
at TCP.onread (net.js:559:26)

If I load the same url in the browser or I user curl from the command line I get the results.

request('[my-url].xml', function(err, response, body){
    // I get the error here in err
});

Any ideea how can I fix this? Thank you!

biancamihai
  • 961
  • 6
  • 14
  • 1
    Any useful answers here? http://stackoverflow.com/questions/17245881/node-js-econnreset – joews Oct 26 '15 at 21:55
  • 1
    Did you try to use node's [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) directly without the `request` module? – thorn0 Oct 26 '15 at 22:19
  • 1
    thank you for your suggestions guys, @thorn I use now http.request with the "Connection":"keep-alive" option and is working great, thank you! – biancamihai Oct 27 '15 at 07:39
  • @biancamihai Did it happen in the middle of download or sometime after it? I'm fighting a similar issue with jsdom that uses `request` internally. But those `ECONNRESET` exceptions happen a few minutes after the request has been completed. – thorn0 Oct 27 '15 at 11:02
  • @thorn in my case it happened in the middle of the download, but this is a big file ... adding the same header also works with request in my case. – biancamihai Oct 27 '15 at 13:02

1 Answers1

2

Two extremely useful troubleshooting tools:

See also:

ADDENDUM:

  • I would definitely encourage you to explore longjohn, Fiddler2 and/or other tools for troubleshooting the HTTP-level requests/responses to and from your application.

  • I noticed joews and I both cited the same Stack Overflow link. Useful takeways:

    a. --abort-on-uncaught-exception node.js option: Not only it provides much more verbose and useful error stack trace, but also saves core file on application crash allowing further debug.

    b. I was facing the same issue but I mitigated it by placing server.timeout = 0; before server.listen.

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • thank you for your suggestions, it was a ""Connection":"keep-alive"" - problem, using this parameter is working – biancamihai Oct 27 '15 at 07:39