[Gmail] IMAP Server constantly (and silently) dies after 24 hours
Hi, for my company's project I found your project, which absolutely fits our needs. We need to retrieve data from a received email, if said mail is delivered by a certain mail address. So far so good, implementation was fine and the new mail event worked. But there's the problem: exactly every 24 hours, the IMAP client dies. No matter how many emails has received, it simply dies. It does not throw errors either, it just close the connection. I've managed to get it up anyway by restarting the client connection, however I would like not to restart it every 24 hours. I can manage to restart it if it gets ECONNRESET or similar errors, but I would like to not recreate the client with such frequency. Any help is deeply appreciated!
Try using keepalive: { forceNoop: true } and see if that helps any.
Already did (my bad for not telling that earlier). This is the snippet of code I've using:
this.mailClient = new Imap({
user: process.env.IMAP_CLIENT_USER,
password: process.env.IMAP_CLIENT_PASSWORD,
host: process.env.IMAP_CLIENT_HOST,
port: Number(process.env.IMAP_CLIENT_PORT),
tls: process.env.IMAP_CLIENT_TLS=="true",
keepalive:{
interval: Number(process.env.IMAP_KEEPALIVE_INTERVAL),
idleInterval: Number(process.env.IMAP_KEEPALIVE_IDLEINTERVAL),
forceNoop: process.env.IMAP_KEEPALIVE_FORCENOOP=="true"
}
})
with the variables as is:
IMAP_KEEPALIVE_INTERVAL=10000
IMAP_KEEPALIVE_IDLEINTERVAL=300000
IMAP_KEEPALIVE_FORCENOOP=true
I've tried keeping the defaults, as well as modify the values (with excessive values in my opinion), but the client still closes the connnection after exactly 24 hours...
maybe late reply, but hope it still helps basically this condition will return false process.env.IMAP_KEEPALIVE_FORCENOOP=="true"
because true is not equal to "true" you should just do this instead
keepalive:{
interval:process.env.IMAP_KEEPALIVE_INTERVAL,
idleInterval: process.env.IMAP_KEEPALIVE_IDLEINTERVAL,
forceNoop: process.env.IMAP_KEEPALIVE_FORCENOOP
}
maybe late reply, but hope it still helps basically this condition will return false process.env.IMAP_KEEPALIVE_FORCENOOP=="true"
because true is not equal to "true" you should just do this instead
keepalive:{ interval:process.env.IMAP_KEEPALIVE_INTERVAL, idleInterval: process.env.IMAP_KEEPALIVE_IDLEINTERVAL, forceNoop: process.env.IMAP_KEEPALIVE_FORCENOOP }
My days, did not saw that... Thank you for the suggestion, however we switched to another IMAP server and we changed the whole implementation, so we are not using this library anymore. Closing as not planned.