I'm using the npm mail-listener-fixed with pm2 connecting to gmail, which utilised imap and mailparser npm packages behind the scenes. I have noticed that after some time the imap connection is timing out with the following error:
21|MailTes | [connection] Error: Error: read ETIMEDOUT
21|MailTes | { Error: read ETIMEDOUT
21|MailTes | at exports._errnoException (util.js:1029:11)
21|MailTes | at TCP.onread [as _originalOnread] (net.js:575:26)
21|MailTes | code: 'ETIMEDOUT',
21|MailTes | errno: 'ETIMEDOUT',
21|MailTes | syscall: 'read',
21|MailTes | source: 'socket' }
21|MailTes | [connection] Closed
21|MailTes | imapDisconnected
My script handles this fine as it then starts a reconnection process, however this behaviour of a timeout occuring only happens when running with PM2.
If I run the same script under screen GNU it will continue sending out idle events and read mail as and when it arrives. Infact I've ran the script for over 2 days now without seeing the timeout happen, where in contrast maybe a few times an hour I see the issue occur under PM2.
I've included extended logs below:
21|MailTes | <= '* OK Gimap ready for requests from xxx.xxx.xxx.xx y10mb6096645ede'
21|MailTes | => 'A0 CAPABILITY'
21|MailTes | <= '* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH'
21|MailTes | <= 'A0 OK Thats all she wrote! y10mb6096645ede'
21|MailTes | => 'A1 LOGIN "xxxx.xxxx.test@gmail.com" "xxxxx"'
21|MailTes | <= '* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584'
21|MailTes | <= 'A1 OK xxx.xxx.test@gmail.com authenticated (Success)'
21|MailTes | => 'A2 NAMESPACE'
21|MailTes | <= '* NAMESPACE (("" "/")) NIL NIL'
21|MailTes | <= 'A2 OK Success'
21|MailTes | => 'A3 LIST "" ""'
21|MailTes | <= '* LIST (\\Noselect) "/" "/"'
21|MailTes | <= 'A3 OK Success'
21|MailTes | => 'A4 SELECT "INBOX" (CONDSTORE)'
21|MailTes | <= '* FLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen $NotPhishing $Phishing)'
21|MailTes | <= '* OK [PERMANENTFLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen $NotPhishing $Phishing \\*)] Flags permitted.'
21|MailTes | <= '* OK [UIDVALIDITY 1] UIDs valid.'
21|MailTes | <= '* 5 EXISTS'
21|MailTes | <= '* 0 RECENT'
21|MailTes | <= '* OK [UIDNEXT 9] Predicted next UID.'
21|MailTes | <= '* OK [HIGHESTMODSEQ 1737]'
21|MailTes | <= 'A4 OK [READ-WRITE] INBOX selected. (Success)'
21|MailTes | imapConnected
21|MailTes | => 'A5 UID SEARCH UNSEEN'
21|MailTes | <= '* SEARCH'
21|MailTes | <= 'A5 OK SEARCH completed (Success)'
21|MailTes | => 'IDLE IDLE'
21|MailTes | <= '+ idling'
21|MailTes | => DONE
21|MailTes | <= 'IDLE OK IDLE terminated (Success)'
21|MailTes | => 'IDLE IDLE'
21|MailTes | <= '+ idling'
21|MailTes | => DONE
21|MailTes | [connection] Error: Error: read ETIMEDOUT
21|MailTes | { Error: read ETIMEDOUT
21|MailTes | at exports._errnoException (util.js:1029:11)
21|MailTes | at TCP.onread [as _originalOnread] (net.js:575:26)
21|MailTes | code: 'ETIMEDOUT',
21|MailTes | errno: 'ETIMEDOUT',
21|MailTes | syscall: 'read',
21|MailTes | source: 'socket' }
21|MailTes | [connection] Closed
21|MailTes | imapDisconnected
21|MailTes | Trying to establish imap connection again
21|MailTes | detaching existing listener
21|MailTes | calling imap connect
21|MailTes | [connection] Connected to host
When running under screen I will continually see the following:
<= 'IDLE OK IDLE terminated (Success)'
=> 'IDLE IDLE'
<= '+ idling'
=> DONE
<= 'IDLE OK IDLE terminated (Success)'
=> 'IDLE IDLE'
<= '+ idling'
=> DONE
<= 'IDLE OK IDLE terminated (Success)'
=> 'IDLE IDLE'
<= '+ idling'
=> DONE
<= 'IDLE OK IDLE terminated (Success)'
=> 'IDLE IDLE'
<= '+ idling'
=> DONE
<= 'IDLE OK IDLE terminated (Success)'
=> 'IDLE IDLE'
<= '+ idling'
=> DONE
<= 'IDLE OK IDLE terminated (Success)'
=> 'IDLE IDLE'
<= '+ idling'
=> DONE
<= 'IDLE OK IDLE terminated (Success)'
=> 'IDLE IDLE'
<= '+ idling'
With mails being parsed as expected, but no read ETIMEDOUT errors at all.
Any help with this is appreciated.
via munkee
No comments:
Post a Comment