Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECONNRESET #47

Open
Revadike opened this issue May 20, 2018 · 12 comments
Open

ECONNRESET #47

Revadike opened this issue May 20, 2018 · 12 comments

Comments

@Revadike
Copy link
Contributor

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

@gustawdaniel
Copy link

It is connected with imap package

mscdex/node-imap#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.

@Revadike
Copy link
Contributor Author

Revadike commented Mar 2, 2019

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

@Revadike
Copy link
Contributor Author

Revadike commented Mar 4, 2019

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

@Revadike
Copy link
Contributor Author

Revadike commented Mar 4, 2019

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?

@gustawdaniel
Copy link

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
Copy link

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

@LoadingCyclone
Copy link

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

@gustawdaniel
Copy link

gustawdaniel commented Aug 28, 2019

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?

@LoadingCyclone
Copy link

LoadingCyclone commented Aug 28, 2019

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

@gustawdaniel
Copy link

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.

@LoadingCyclone
Copy link

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

@gustawdaniel
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants