Closed Adibla closed 3 years ago
My findings:
socketTimeout
defaults to 0 and will timeout depending on OS or never
error
event otherwise it will kill your processsocketTimeout
close
event and reconnectthis is my current working test
async connect () {
const me = this
try {
if (!this._c) {
this._c = await imaps.connect(this.config)
this.log.info(`IMAP connected to ${this.config.imap.host}`)
this._c.on('error', err => {
// THIS IS REQUIRED not to crash the process on socket error
this.log.error(err)
})
this._c.imap.on('close', () => {
this._c = null
setTimeout(() => {
this.log.debug('IMAP reconnecting after error')
me.connect()
}, RECONNECT_TIMEOUT)
})
}
await this._c.openBox('INBOX')
this.log.info('IMAP INBOX opened')
} catch (ex) {
this.log.error(ex)
setTimeout(() => {
this.log.debug('IMAP initial reconnect')
me.connect()
}, RECONNECT_TIMEOUT)
}
}
Hi, I've an issue. I tried to do some tests and I saw that if I establish the connection with my imap server and I disconnect my computer from the internet connection and then I reconnect to it, the library seems blocked, and no one Promise.catch are triggered. I don't find the problem and I've no idea how to catch it. Thank you.