Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gmail] IMAP Server constantly (and silently) dies after 24 hours #921

Open
en-nicolabaesso opened this issue Sep 20, 2024 · 2 comments
Open

Comments

@en-nicolabaesso
Copy link

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!

@mscdex
Copy link
Owner

mscdex commented Sep 20, 2024

Try using keepalive: { forceNoop: true } and see if that helps any.

@en-nicolabaesso
Copy link
Author

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants