I have an API for downloading files using res.download. It works fine when single call is made.
However, when bulk call (e.g. call 10 times within 1 second), several of the request are failed and prompt below error:
Error: read ECONNRESET
Can anyone explain this behavior? Thanks in advance.
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one or more application protocol errors. You could look at the API server logs to see if it complains about something.
How do I debug error ECONNRESET in Node.js?
Your best bet is to make sure you are not throttling the API.
Related
Sometimes when I restart my Tinylicious server, I receive the following error many times in the server logs.
Connect Document error: {} {"messageMetaData":{"documentId":"1608426861167","tenantId":"tinylicious"},"label":"winston","timestamp":"2020-12-20T21:20:50.591Z"}
What exactly does this error mean and how can I fix it?
This error is created when we fail to make a socketio connection. You can see our code to create the connection here and the error message you're seeing here.
I don't believe this error will cause you significant issues, but it shouldn't be there. There's an issue on the project's github that you can add to if you're looking for more information.
I have a front application which is calling a microservice both in nodejs
I do not really understand why from time to time the http call on internal url http://service.env:3027 is returning connect ECONNRESET 100.66.156.188:3027
Should be aprox on 0.1% of the requests but I can not understand why
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one or more application protocol errors. You could look at the API server logs to see if it complains about something.
It's probably related to clients connected to your frontend just closed the browser in the middle of the request - I wouldn't be to worry about that as long as it stays low in numbers.
I am using arangojs v6.14.1 and arangodb version 3.6.4.. I also have the nodejs express app which is intended to serve client requests.
I am experiencing an issue while executing concurrent requests. The database connection hangup when I concurrently process client requests:
What the app will do when it receives a request?
Open a database connection -
db = new Database(dbConfig.url);
db.useDatabase(dbConfig.name);
db.useBasicAuth(dbConfig.username, dbConfig.password);
There are multiple middleware functions that need to access to perform various functions and accessibility checks. And for each middleware I tried to
open a new database connection ->
perform the action ->
close the connection ->
return the result to next middleware.
This works fine with single request at a time. But if I tried to call two APIs at same time, I am getting CONNECTIONRESET error. And also throwing socket hangup error.
I tried to commend out the close connection method and it started working fine for a while. But when I increased the number of connections, it again showing the same error as "CONNECTIONRESET".
I have searched the documentation of arangojs regarding the connection manipulation. But I haven't found any information regarding the same.
Any help would be deeply appreciated.
This might be too late for you, but I had a similar issue. After talking with ArangoDB support, it turned out to be an issue with sockets.
Looking at the output from netstat -aplnt I was seeing a lot of CLOSE_WAIT and TIME_WAIT messages, indicating that there were A LOT of connections that were not being closed properly.
The solution was to enable persistent connections (see arangojs config for keep-alive and maxSockets) and then re-using a single connection whenever possible. This was more than just a settings change, requiring some code modifications as well.
I am building an applications using Node.js, Express and Mongoose. I am using Cloud9 for a development environment. I used express generator to create the base of my app and have been adding onto it.
I seemingly randomly get this error and the server stops. It doesn't happen during any specific event, it happens in between page loads. It doesn't seem to happen to any specific pages.
I get this error all the time, and I'm constantly having to start it again.
events.js:141
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at exports._errnoException (util.js:870:11)
at TCP.onread (net.js:552:26)
MongoDB does not crash when I get this error. I just have to start the node server again and it works fine. Until it randomly crashes again.
I'm not sure if this error is just a side-effect of C9, if so I'm not worried about it, I just don't want it to happen in production, especially since I can't see the logs nearly as easily.
If I really am failing to "handle the error" I'd like to know where I'm supposed to do that, I would much prefer my server to not crash when it gets a problem.
In node, whenever an 'error' event is emitted and no one listens to it, it will throw.
To make it not throw, put a listener on it and handle it yourself. That way you can log the error with more information.
You can also try using the useful node.js option --abort-on-uncaught-exception. Not only it provides much more verbose and useful error stack trace, but also saves core file on application crash allowing further debug.
To have one listener for a group of calls you can use domains and also catch other errors on runtime. Make sure each async operation related to http(Server/Client) is in different domain context comparing to the other parts of the code, the domain will automatically listen to the error events and will propagate it to it's own handler. So you only listen to that handler and get the error data. You also get more information for free here.
See also this SO answer...
You can use pm2 for starting your server. Then your server will not crash if there is any error. It will just throw the error and continue to run. It also other useful features as well.
You can read more about pm2 here https://www.npmjs.com/package/pm2
Currently, I am working on a REST API using the Node hapijs framework. The API is deployed on Heroku.
There is a GET endpoint in the API that makes a get request to retrieve data from a third party and processes the data before sending a reply. This particular endpoint times out from time to time. When the endpoint times out, Heroku returns an H12 error. Once it has timed out, subsequent requests to that endpoint result in the H12 errors. I have to restart the application on Heroku to get that endpoint working again. No other endpoints in the API are affected in any way by this error and continue to work just fine even after the error has ocurred.
In my debugging process and looking through the logs, it seems that there are times when a response is not returned from the third party API, causing the error.
I've tried the following solutions to try and solve the problem:
I am using the request library to make requests. Hence, I've tried setting a timeout to 5000 ms as part of the options passed in to the request. It has worked at times... the timeout is triggered and the endpoint sends the timeout error associated with request. This is the kind of behavior that I would like, since subsequent requests to the endpoint work. However, there are times when the request timeout is not triggered but Heroku still returns an H12 error (always after 30 seconds, the Heroku default). After that, subsequent requests to that endpoint return the H12 error (also after 30 seconds). It seems that some sort of process gets "stuck" on Heroku and is not terminated until I restart the app.
I've tried adding a timeout to the hapi.js route config object. I get the same results as above.
I've continued doing research and suspect that the issues has to do with the description given here and here. It seems like setting a timeout at the app server level that can send a SIGKILL to the Heroku worker might do the trick. It seems fairly straightforward in Ruby but I cannot find much information on how to do this in Node.
Any insight is greatly appreciated. I am aware that a timeout might occur when making a request to a third party. That is not the issue. The issue is that the endpoint seems to get "stuck" on Heroku after a timeout and it becomes unresponsive.
Thanks for the help!
I had a similar issue and after giving up for a day, I came back to it and found my error. I wasn't sending a response to the client when an error occurred on the server side. Make sure you are returning a response no matter what the result of your server side algorithm is. If there is an error, return that. If the request was successful, return that response. I hope that helps.
If that doesn't help, check heroku's guides on handling Request Timeouts, especially the Debugging request timeouts section could be of help: