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

error sending message '[Title]': remote error: tls: user canceled #1717

Closed
kulterryan opened this issue Feb 6, 2024 · 9 comments
Closed
Labels
needs-investigation Potential bug. Needs investigation

Comments

@kulterryan
Copy link

Version:

  • listmonk: [eg: v1.0.0]
  • OS:Ubuntu/Railway

Description of the bug and steps to reproduce:
Getting TLS error after a specific time interval when logged in the application.

Screenshots:
image

@knadh
Copy link
Owner

knadh commented Feb 6, 2024

hm, sounds like an an SMTP/TLS configuration issue. What SMTP provider are you using?

@knadh knadh added the needs-investigation Potential bug. Needs investigation label Feb 6, 2024
@kulterryan
Copy link
Author

kulterryan commented Feb 6, 2024

I'm using AWS SES. Here're the configurations:
image

@knadh
Copy link
Owner

knadh commented Mar 8, 2024

Unable to reproduce this with SES in production. Could've something to do with network configuration.

@knadh knadh closed this as completed Mar 8, 2024
@simenghe
Copy link

Also getting this problem with SES.

@MaximilianKohler
Copy link
Contributor

MaximilianKohler commented Mar 21, 2024

I just started getting this with SES as well on v2.5.1. I've been sending 2-3k emails per day without issue and gradually increased it to 50k, and it happened for the first time now even though my SES limit is 500k.

2024/03/21 08:52:00 start processing campaign (<campaign name> 2024-03-21 50k)
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968723: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968726: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968724: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968725: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968728: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968727: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968729: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968730: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968731: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968732: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968734: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968733: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968735: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968737: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968739: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968740: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968741: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968743: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968747: remote  error: tls: user canceled
2024/03/21 09:12:01 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 968748: remote  error: tls: user canceled
2024/03/21 09:23:47 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 983818: 421 Connection closed by server. Too many messages in one session
2024/03/21 09:23:48 error sending message in campaign <campaign name> 2024-03-21 50k: subscriber 983829: remote  error: tls: user canceled
2024/03/21 09:31:23 campaign (<campaign name> 2024-03-21 50k) finished

Per the timestamps, it looks like it happened to 21 users about halfway through and then carried on normally.

Are you saying this has to do with my server provider (Hetzner)?

Screenshot 2024-03-21 101551
Screenshot 2024-03-21 101613
Screenshot 2024-03-21 101626
Screenshot 2024-03-21 103859

EDIT: if anyone wants to try resending the emails to only the errored subscribers, here are directions: #1629 (comment)

@MaximilianKohler
Copy link
Contributor

MaximilianKohler commented Mar 24, 2024

I tried lowering the send rate from 10x10 to 10x7 and then 10x5 and it still happens. I thought it might be the recipient email server (gmail, hotmail, etc.) rejecting my emails, but looking at the subscribers it failed for, they're very diverse. IE: they're not all from gmail or hotmail, but many providers.

After lowering it to 10x5 it didn't take long for it to start giving errors, and then the errors occurred sporadically throughout:

2024/03/24 08:58:04 start processing campaign (<campaign name>)
2024/03/24 09:18:04 error sending message in campaign <campaign name>: subscriber 359952: 421 Connection closed by server. Too many messages in one session
2024/03/24 09:18:04 error sending message in campaign <campaign name>: subscriber 359962: 421 Connection closed by server. Too many messages in one session
2024/03/24 09:18:04 error sending message in campaign <campaign name>: subscriber 359966: remote error: tls: user canceled
2024/03/24 09:18:04 error sending message in campaign <campaign name>: subscriber 359955: remote error: tls: user canceled

So from 8:58 to 9:18 it couldn't have even sent that many messages at 10x5.

@MaximilianKohler
Copy link
Contributor

MaximilianKohler commented Apr 5, 2024

I found this https://stackoverflow.com/questions/49111453/sending-email-with-aws-ses-via-smtp-error-421 which says it might be solved by changing the port. Here's another discussion on that: TLS port 465 vs STARTTLS port 587

I switched to STARTTLS 587 and got the exact same errors.

@MaximilianKohler
Copy link
Contributor

MaximilianKohler commented Apr 5, 2024

@knadh An Amazon expert replied: https://repost.aws/questions/QULOBzwPLMS2GkrUgOjWNshQ/amazon-ses-remote-error-tls-user-canceled-421-connection-closed-by-server-too-many-messages-in-one-session

Hi there

Can you provide some details on how your application is sending mail? Is it using some sort of keep alive to hold a connection open to the SMTP server? If so, you might want to try limiting that. Also, do you have any retry/backoff in your application code?

See https://docs.aws.amazon.com/ses/latest/dg/troubleshoot-smtp.html#troubleshoot-smtp-response-codes

You should retry SMTP requests that receive 400 errors. We recommend that you implement a system that retries requests with progressively longer wait times (for example, wait 5 seconds before retrying, then wait 10 seconds, and then wait 30 seconds). If the third retry doesn't succeed, wait 20 minutes, and then repeat the process. To see an example of an implementation that uses an exponential retry policy, see How to handle a "Throttling - Maximum sending rate exceeded" error on the AWS Messaging and Targeting Blog.

@MaximilianKohler
Copy link
Contributor

Hetzner says it's not a limitation on their end.

So the solution seems to be increasing the default "retries" from 2 to 4 under /admin/settings -> SMTP, but only if there's a progressive delay implemented as the Amazon guy said.

Does listmonk have a progressive delay? If not, that would be the solution no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation Potential bug. Needs investigation
Projects
None yet
Development

No branches or pull requests

4 participants