Re: [exim]  421 Too many concurrent connections from this c…

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Phil Pennock
Datum:  
To: g18c
CC: exim-users
Betreff: Re: [exim]  421 Too many concurrent connections from this client
On 2012-10-14 at 00:50 +0400, g18c wrote:
> We have a Kayako helpdesk, when e-mails come in from customers notifications are sent out by Kayako to a number of staff whose mailboxes are hosted on Rackspace mail servers.
>
> Rackspace policy is 5 connections to their mx1 and 3 connections to mx2.
>
> I noticed a large number of queued messages in Exim - when looking in Exim logs I can see many lines 2012-10-13 20:06:56 1TN72s-0007Cw-1l SMTP error from remote mail server after initial connection: host mx2.emailsrvr.com [173.203.2.32]: 421 Too many concurrent connections from this client.
>
> For our requirements if we send 1 email every 10 seconds or so, this would be OK.
>
> Messages to all other servers should go through a normal rates, only mx1.emailsrvr.com and mx2.emailsrvr.com should have this connection limit policy applied.
>
> Is this possible?


You can increase the _likelihood_ of limiting yourself to a maximum
number of connections per IP, but not be _sure_ to prevent it.

If you can build a list of domains, then the easy way is to set the
"queue_smtp_domains" option to a domain-list (which can be a lookup, per
normal domain-list rules); mails to those domains won't be immediately
delivered, but routing will have been done. A later queue runner will
collect all emails to the same IP destination and shove them down one
SMTP connection (subject to various maximum limits).

So you then run a queue runner once per minute. If you _really_ need to
pump more often, write a small script which sleeps 10 seconds between
calling "exim -R @domain.to.trigger" (to avoid retrying messages for
other domains).

I might be missing a really easy way to extend this to hosts instead,
but I'd try a dnsdb lookup for the special "mxh" keytype.

Assuming Exim 4.77 or more recent, for the inlisti operation:

queue_smtp_domains = ${if forany{${lookup dnsdb{mxh=$domain}}}{inlisti{$item}{mx1.emailsrvr.com:mx2.emailsrvr.com}} {*}{}}

(untested!)

That says "if, for any of the hostnames resulting from looking up the
domain's MX records in DNS and taking the hostname part of the MX
records, that hostname is in the list consisting of these two hosts,
then '*', else the empty string", and results in a domainlist of one or
zero items, used for matching.

If you're using an older Exim release then:
 (1) I of course encourage you to use Exim 4.80 and in general to stay
     up-to-date
 (2) in the meantime, you can nest a second forany{} inside the first
     one, and try to stay sane while doing so.  That way lies madness
     and despair in your debugging.  Use inlisti{needle}{hay:stack}
     instead.  The "i" is case-Insensitive matching.


-Phil