node:events:368
throw er; // Unhandled 'error' event
^
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (node:net:474:14)
at JSStreamSocket.doWrite (node:internal/js_stream_socket:175:19)
at JSStream.onwrite (node:internal/js_stream_socket:33:57)
at TLSSocket.Socket._final (node:net:443:28)
at callFinal (node:internal/streams/writable:695:27)
at prefinish (node:internal/streams/writable:724:7)
at finishMaybe (node:internal/streams/writable:734:5)
at TLSSocket.Writable.end (node:internal/streams/writable:632:5)
at TLSSocket.Socket.end (node:net:609:31)
at endWritableNT (node:internal/streams/readable:1369:12)
Emitted 'error' event on MailListener instance at:
at MailListener.imapError (/Users/zeev/Documents/matrix/matrix-googlevoice/matrix-googlevoice-bot.js:172:26)
at Connection.emit (node:events:390:28)
at TLSSocket._onError (/Users/zeev/node_modules/imap/lib/Connection.js:151:10)
at TLSSocket.emit (node:events:390:28)
at TLSSocket._emitTLSError (node:_tls_wrap:900:10)
at JSStreamSocket.<anonymous> (node:_tls_wrap:819:36)
at JSStreamSocket.emit (node:events:390:28)
at Socket.<anonymous> (node:internal/js_stream_socket:63:38)
at Socket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:164:8) {
code: 'EPIPE',
source: 'socket'
}
There's nothing this module can do about that, you just have to reconnect when that happens. Maybe gmail has a maximum imap session time limit? :man_shrugging:
No matter what I do, I keep losing connection to Gmail after a few hours.
I've tried adding
keepalive
options, as well as trying to create anew Imap()
when a disconnect happens.My code is at https://github.com/dzg/matrix-googlevoice/blob/main/matrix-googlevoice-bot.js
Sometimes I'll get an error: