Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Mattermost
  3. Too many concurrent SMTP connections

Too many concurrent SMTP connections

Scheduled Pinned Locked Moved Solved Mattermost
smtp
5 Posts 2 Posters 2.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tomw
    wrote on last edited by
    #1

    Hi everyone,

    I am using the Cloudron built-in SMTP server for the domain Mattermost sends email from and I just noticed in my logs that when sending a notification email to many users at once (e.g. resulting from an @all) , lots of them fail with an error like the following:

    {"level":"error","ts":1614543114.932735,"caller":"app/notification_email.go:105","msg":"Error while sending the email","user_email":"[DELETED]","error":"SendMail: Failed to open TLS connection., 421 Too many concurrent connections"}
    

    It looks like Mattermost tries to send all the emails at once and there is no retry logic, so the result of this is that only a fraction of the users will receive the notification emails that are expected. There is an upstream bug to add a configurable maximum number of connections that has been open since 2016.

    I guess when using an external mail service, the large number of concurrent connections may not be a problem. For example, Sendgrid states that up to 10,000 concurrent connections from a single server are permitted.

    However if possible I would like to stick with the built-in SMTP server so that it is not necessary to pass this data through a third party. In my case there are around 60 people in the Mattermost team, so that should be the theoretical maximum number of emails being sent simultaneously.

    I am wondering if it would be practical to bump up the number of simultaneous connections allowed by the built-in SMTP server to 60 without causing problems? Or if anyone has any other ideas for a way around this problem?

    Tom

    girishG 1 Reply Last reply
    0
    • T tomw

      Hi everyone,

      I am using the Cloudron built-in SMTP server for the domain Mattermost sends email from and I just noticed in my logs that when sending a notification email to many users at once (e.g. resulting from an @all) , lots of them fail with an error like the following:

      {"level":"error","ts":1614543114.932735,"caller":"app/notification_email.go:105","msg":"Error while sending the email","user_email":"[DELETED]","error":"SendMail: Failed to open TLS connection., 421 Too many concurrent connections"}
      

      It looks like Mattermost tries to send all the emails at once and there is no retry logic, so the result of this is that only a fraction of the users will receive the notification emails that are expected. There is an upstream bug to add a configurable maximum number of connections that has been open since 2016.

      I guess when using an external mail service, the large number of concurrent connections may not be a problem. For example, Sendgrid states that up to 10,000 concurrent connections from a single server are permitted.

      However if possible I would like to stick with the built-in SMTP server so that it is not necessary to pass this data through a third party. In my case there are around 60 people in the Mattermost team, so that should be the theoretical maximum number of emails being sent simultaneously.

      I am wondering if it would be practical to bump up the number of simultaneous connections allowed by the built-in SMTP server to 60 without causing problems? Or if anyone has any other ideas for a way around this problem?

      Tom

      girishG Offline
      girishG Offline
      girish
      Staff
      wrote on last edited by
      #2

      @tomw the concurrency is set quite low at the moment - just 5. There's no issue bumping this value, it was just a very conservative setting.

      As a temporary fix:

      • docker exec -ti mail /bin/bash
      • Edit the file /run/haraka/config/limit.ini. There is a concurrency section under which max is set to 5. Make is say 200.
      • supervisorctl restart haraka

      Does that make things work? The configuration does not survive server restarts, but I will bump it in the next release.

      T 1 Reply Last reply
      0
      • girishG girish

        @tomw the concurrency is set quite low at the moment - just 5. There's no issue bumping this value, it was just a very conservative setting.

        As a temporary fix:

        • docker exec -ti mail /bin/bash
        • Edit the file /run/haraka/config/limit.ini. There is a concurrency section under which max is set to 5. Make is say 200.
        • supervisorctl restart haraka

        Does that make things work? The configuration does not survive server restarts, but I will bump it in the next release.

        T Offline
        T Offline
        tomw
        wrote on last edited by
        #3

        @girish said in Too many concurrent SMTP connections:

        Does that make things work?

        Brilliant, thanks @girish! I have made the change and will report back next time someone sends an @all message.

        T 1 Reply Last reply
        0
        • T tomw

          @girish said in Too many concurrent SMTP connections:

          Does that make things work?

          Brilliant, thanks @girish! I have made the change and will report back next time someone sends an @all message.

          T Offline
          T Offline
          tomw
          wrote on last edited by
          #4

          Update: We have successfully triggered emails with an @all to 46 people without errors, so the fix seems to have worked. 👍

          girishG 1 Reply Last reply
          1
          • T tomw

            Update: We have successfully triggered emails with an @all to 46 people without errors, so the fix seems to have worked. 👍

            girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #5

            @tomw thanks for the update! I will make the default value higher in the next release.

            1 Reply Last reply
            1
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Bookmarks
            • Search