Node-imap results in ECONNRESET when using Office365 and xoauth2

46 views Asked by At

The proces is organized as follows:

  1. A Node-imap connects to Office365 user mailbox and reads ["UNSEEN"] messages.
  2. Parses the attachments and if found - creates a db entry and stores the message UID.
  3. After 15 second delay, a second process starts that executes a for() loop and goes through all the UIDs, once again connects to inbox, parses attachments and then streams them to filesystem as well as posts them to an API.

When there is only 1 attachment in the e-mail messaage, the secondary process almost always ends correctly, however if there's more than one attachment, process after connecting to inbox, reading message (by UID), parsing the attachments and then via an "ON" event sending them to filesystem and API - always runs into ECONNRESET error.

Is there perhaps a configuration in Office365 that causes that, or am I doing something entirely wrong with this approach?

0

There are 0 answers