Koozali.org: home of the SME Server

Too many connections: 10 >= 10. Waiting one second.

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #30 on: October 26, 2018, 10:25:20 PM »
I understand the risk. I can put this on a test machine, but I am not sure I can replicate the source of the condition.

I can stand by the production machine and revert the changes quickly if necessary.
- Mark

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #31 on: October 26, 2018, 11:25:20 PM »
You can replicate by following the comments in the bug.

I think Daniel explained how to test.

https://bugs.contribs.org/show_bug.cgi?id=10639#c8

There may be a commemt here in this thread too.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #32 on: October 26, 2018, 11:49:46 PM »
The patched server is behaving fine. I do see that the source of the overload is still active. However, the logs suggest the server is managing it OK.

I am tempted to ban the address and see if someone on the other end squeals.

Now, the change was only the reordering of the parameters in the service run script, as posted by mccarn. I have not changed the fail2ban regex.
- Mark

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #33 on: October 26, 2018, 11:55:50 PM »
The question is does attempt no 6 get blocked?

Open another terminal and tail the sqpsmtpd log while telnetting in the first.

Look for connection 'x of y' eg 0/10, 1/10 etc.

It should ignore connections after no 5

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #34 on: October 27, 2018, 12:18:23 AM »
Looking at forkserver it appears a connection made every 22 minutes.

The sqsmptd log shows "Accepted connection 3/15 from ... / Unknown"
- Mark

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #35 on: October 27, 2018, 12:25:49 AM »
Sorry thought you were on a test machine.

All you can do is monitor. To test you need to follow the instructions and see if it locks out the IP.

Right. Way past my bed time. Hasta maƱana :-)
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #36 on: October 27, 2018, 12:30:53 AM »
Thanks for all the help. I really appreciate it.

I will check on this about 19:30 pacific time and post the outcome.
- Mark

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #37 on: October 27, 2018, 12:40:14 AM »
KK. NP. Ciao.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #38 on: October 27, 2018, 12:40:51 AM »
A question, for later, does come to mind: where is the limit value of 15 set?

cat  /var/service/sqpsmtpd/runenv
reveals this...
INSTANCES=10
INSTANCES_PER_IP=5
- Mark

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #39 on: October 27, 2018, 12:48:32 AM »
Mentioned earlier in thread I think :-)

Also possibly on the bug.

You can also have a dig in the templates to see for yourself.

Try looking in:

/etc/e-smith/templates/var/service/sqpsmtpd/runenv/
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #40 on: October 27, 2018, 04:40:36 AM »
I checked the server at 19:15 pacific time and the "Too many connections: 15 >= 15.  Waiting one second." entries were filling the log. forkserver reported the 15 connections.

To recap, it appears the changes to the service run script, as posted by mccarn, did not work around the bug in my case. I did not update the regex in the fail2ban, however.

I have manually banned the offending IP address for now. I will revisit this after some sleep.
- Mark

Offline mmccarn

  • *
  • 2,626
  • +10/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #41 on: October 27, 2018, 06:30:27 AM »
A question, for later, does come to mind: where is the limit value of 15 set?

15 is the default value of INSTANCES in /usr/bin/qpsmtpd-forkserver itself:
Quote from: /usr/bin/qpsmtpd-forkserver
# Configuration
my $MAXCONN = 15;    # max simultaneous connections
my @PORT;            # port number(s)
my @LOCALADDR;       # ip address(es) to bind to
my $MAXCONNIP = 5;   # max simultaneous connections from one IP
my $PID_FILE  = '';
my $DETACH;          # daemonize on startup
my $NORDNS;

Look for the actual running parameters; if you're missing the "-c ##" argument, you'd end up with 15.  Of course, if you have it and it's set to 15, you'd have 15 (but you'd need to figure out why it's set to 15...)
Quote from: ps auxwww |grep qpsmtpd
root       966  0.0  0.0    108    24 ?        Ss   Oct25   0:00 runsv qpsmtpd
root       999  0.0  0.0    108    20 ?        Ss   Oct25   0:00 runsv sqpsmtpd
smelog    1012  0.0  0.0   4072   396 ?        S    Oct25   0:00 /usr/local/bin/multilog t s5000000 n30 !/usr/local/bin/qplogsumm.pl /var/log/qpsmtpd
smelog    1024  0.0  0.0   4072   392 ?        S    Oct25   0:00 /usr/local/bin/multilog t s5000000 n30 /var/log/sqpsmtpd
qpsmtpd   2468  0.0  0.6 119424 27840 ?        S    Oct25   0:14 /usr/bin/perl -Tw /usr/bin/qpsmtpd-forkserver -u qpsmtpd -l 0.0.0.0 -m 5 -c 40 -p 25
qpsmtpd  30635  0.0  0.6 119424 28008 ?        S    Oct26   0:06 /usr/bin/perl -Tw /usr/bin/qpsmtpd-forkserver -u qpsmtpd -l 0.0.0.0 -p 465 -m 5 -c 10

Offline Mophilly

  • *
  • 384
  • +0/-0
    • Mophilly
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #42 on: October 27, 2018, 05:36:57 PM »
Thank you. I ran the current state test.
Code: [Select]
qpsmtpd  26194  0.0  0.2  71908 16148 ?        S    Oct26   0:03 /usr/bin/perl -Tw /usr/bin/qpsmtpd-forkserver -u qpsmtpd -l 0.0.0.0 -p 25 -c 40 -m 5
qpsmtpd  26326  0.0  0.2  71908 16140 ?        S    Oct26   0:02 /usr/bin/perl -Tw /usr/bin/qpsmtpd-forkserver -u qpsmtpd -l 0.0.0.0 -p 465

I notice that the -m and -c parameters are absent for port 465. Perhaps that is something I should fix?

The offending IP address was released from jail at 05:21 pacific time today. The connections resumed ten minutes later and continue on the 22 minute period.

If I modify the fail2ban regex, will that suffice as a work around?

I noticed updates to bugs 10639 and 10387. Perhaps changing the crontab as suggested is a better approach. Thoughts?

Update: I created a custom template for crontab and rebooted the machine. I am waiting to see if the offending connections are held at bay.
« Last Edit: October 27, 2018, 07:52:52 PM by Mophilly »
- Mark

Offline mmccarn

  • *
  • 2,626
  • +10/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #43 on: October 27, 2018, 09:20:52 PM »
I notice that the -m and -c parameters are absent for port 465. Perhaps that is something I should fix?

Yes.  My guess is that you're missing the trailing "\" at the end of the port line in /var/service/sqpsmtpd/run (colored red in the extract below):
Quote from: /var/service/sqpsmtpd/run
...
exec /usr/local/bin/softlimit -d ${SOFTLIMIT:-25000000} -s ${SOFTLIMIT:-25000000} -l ${SOFTLIMIT:-25000000} \
  /usr/bin/qpsmtpd-forkserver \
        -u qpsmtpd \
        -l 0.0.0.0 \
        -p ${PORT:-465} \
        -c ${INSTANCES:-40} \
        -m ${INSTANCES_PER_IP:-5}

...

You would get the same behavior if the backslash is there but has a space after it - "\ " instead of "\"

Offline ReetP

  • *
  • 3,731
  • +5/-0
Re: Too many connections: 10 >= 10. Waiting one second.
« Reply #44 on: October 28, 2018, 01:00:17 AM »
Fail2ban seems to work for me.

Set these:

Code: [Select]
fail2ban=service
    BanTime=1800
    FindTime=900

I set the /etc/fail2ban/jail.conf template for qpsmtpd to max 3 retries

Copied this to a custom template:

/etc/e-smith/templates/etc
fail2ban/jail.conf/30Service20qpsmtpd

Then changed this

Code: [Select]
my $max = $maxretry*3;

To this

Code: [Select]
my $max = 3;

So we get this:

Cat /etc/fail2ban/jail.conf

Quote
Blah....
[qpsmtpd]
enabled  = true
filter   = qpsmtpd
logpath  = /var/log/*qpsmtpd/current
maxretry = 3
Blah

So more than 3 attempts get picked up (choose your own values)

Add the regex and signal-event fail2ban-conf

Obviously YMMV and it may need tweaking. It may be better to separate qpsmtpd and sqpsmtpd so you can have different settings. Currently the ban mail tells me it's qpsmtpd when it could be actually a ban from sqpsmtpd. I'll look at it more when home.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation