nodejs-mail-notifier
nodejs-mail-notifier copied to clipboard
ECONNRESET
{ Error: read ECONNRESET at _errnoException (util.js:1019:11) at TCP.onread (net.js:608:25) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read', source: 'socket' }
I see those constantly. What's causing it?
It is connected with imap package
https://github.com/mscdex/node-imap/issues/710
If error is unhandled then it create error event on Connection object.
https://github.com/mscdex/node-imap/blob/master/lib/Connection.js#L151
And it is not the same as close and end. Please tell me @Revadike if you
still experiencing this bug, or your merge fixed it? Let me know which node
version do you have.
In my opinion connection after this error should be closed and reestablished.
But it should be done in imap package. Then your fix should work.
I haven't been using this for months now. I disabled any email features in my app. I'll look into it again.
Still doesn't seem to be solved. I can't even get new mail event to fire after the first ones.
I think I fixed the ECONNRESET, but it's probably too early to say. However, I can't get it to detect new email. Is there a delay? If so, how long?
I'm doing this:
"search": [`UNSEEN`, [`SINCE`, new Date(Date.now() - 900000).toISOString()]]
Is this right?
I think it can be fixed by handling it manually by the end user of the package. For example instead:
const n = notifier(imap);
n.on('end', () => n.start()) // session closed
.on('mail', mail => console.log(mail.from[0].address, mail.subject))
.start();
User of this package should type
const n = notifier(imap);
n.on('end', () => n.start()) // session closed
.on('error', () => { if(error.code === 'ECONNRESET') { setTimeout(() =>{ n.stop(); n.start(); }, 5000); }})
.on('mail', mail => console.log(mail.from[0].address, mail.subject))
.start();
Most confusing for me was if ECONNRESET finish connection or not. And it seems that in imap package close event is not fired on error ECONNRESET. Your pull request was probably done with this assumption.
I experiencing ECONNRESET because of problems with my network infrastructure (what not depend on
the code of this package).
Was this ever resolved? I'm still having this issue.
Last merged pull request from 14 Dec 2018, my pull request not closed, not merged, not commented. This is probably not resolved. To resolve we probably need to write test for this bug.
Can you @LoadingCyclone describe steps to reproduce?
@gustawdaniel I'm sorry I can't my program runs for a while and it works fine for a while but I don't know what actually triggers the error. All I know is after around 2 to 3 days I get an ECONNRESET crash log. Next time it happens I'll try to track it further.
I tried adding the error handler as described above
.on('error', () => { if(error.code === 'ECONNRESET') { setTimeout(() =>{ n.stop(); n.start(); }, 5000); }})
and still had the crash this morning. That gave me a separate one however saying that error is undefined. So I threw in this to try to resolve that issue. If that resolves it I'll let you know.
.on('error', (error) => { if(error.code === 'ECONNRESET') { setTimeout(() =>{ n.stop(); n.start(); }, 5000); }})
I was fighting with this bug a some days and finally switched to external service that listen on emails.
For example:
- zapier - more known and more friendly user interface
- integromat - better pricing and support for email attachments
I selected integromat. Then in my system created api endpoint and communicated it with mentioned service finally removing this package from my code.
@gustawdaniel Is integromat quick with sending the event once it receives an email? My application needs the event to be fired ASAP.
Using this package I had emails in saved in database in 4 seconds from sending by sender.
In integromat there is 15 or 5 min - it depends from pricing plan.