I am getting a connection reset error. I am fairly certain this is coming from a long running REST request, that is timing out.
{ [Error: socket hang up] code: 'ECONNRESET' }
Is there a way to disable request timeouts in Koa, so that I can test this hypothesis?
I am running node version 5.x, koa 0.10, centOs 6
It seems your request take longer than default Koa timeout. Default Koa timeout is 2 minutes
I had similar problem one request take more time than 2 minutes.
I was inspirate by zeronone commend in this post, and finally this line helped to me
ctx.request.socket.setTimeout(5 * 60 * 1000);
so whole code in router could look like
router.post('/long-request', async (ctx) => {
// set timeout to 5 minutes
ctx.request.socket.setTimeout(5 * 60 * 1000);
// do some stuf what take long time
// but less than 5 minutes
});
I really don't recommend do request what take longer than 1 minute, ideally run the heavy stuff on separate process and by other request just check if is the work done.
So that could be good just for testing purposes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With