nodejs-mail-notifier icon indicating copy to clipboard operation
nodejs-mail-notifier copied to clipboard

ECONNRESET

Open Revadike opened this issue 7 years ago • 12 comments

{ 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?

Revadike avatar May 20 '18 12:05 Revadike

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.

gustawdaniel avatar Mar 01 '19 21:03 gustawdaniel

I haven't been using this for months now. I disabled any email features in my app. I'll look into it again.

Revadike avatar Mar 02 '19 11:03 Revadike

Still doesn't seem to be solved. I can't even get new mail event to fire after the first ones.

Revadike avatar Mar 04 '19 20:03 Revadike

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?

Revadike avatar Mar 04 '19 22:03 Revadike

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.

gustawdaniel avatar Mar 05 '19 14:03 gustawdaniel

I experiencing ECONNRESET because of problems with my network infrastructure (what not depend on the code of this package).

gustawdaniel avatar Mar 05 '19 14:03 gustawdaniel

Was this ever resolved? I'm still having this issue.

LoadingCyclone avatar Aug 28 '19 13:08 LoadingCyclone

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 avatar Aug 28 '19 16:08 gustawdaniel

@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); }})

LoadingCyclone avatar Aug 28 '19 18:08 LoadingCyclone

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 avatar Sep 11 '19 18:09 gustawdaniel

@gustawdaniel Is integromat quick with sending the event once it receives an email? My application needs the event to be fired ASAP.

LoadingCyclone avatar Sep 11 '19 18:09 LoadingCyclone

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.

gustawdaniel avatar Oct 23 '19 12:10 gustawdaniel