mosquitto: increase connection limits

Asked by mukilan on 2020-10-19

I am trying to increase my mosquitto connection limits. when my mosquitto broker reaches above 1010 clients connection it's cannot publish a message and got connection failed error. $SYS/broker/clients/active this command used to I checked it. I attach my config files given below.

My server specification:

Server: ubuntu 18.04 LTS Mosquitto version:1.6.12 Ram:4GB

My configurations:

Our system wide open connections is configured on /etc/sysctl.conf:

fs.file-max =200000

In /etc/security/limits.conf:

* hard nofile 200000
* soft nofile 200000

root hard nofile 200000
 root soft nofile 200000

Mosquitto is installed under the user 'Ubuntu'.

We also added below line of code on /etc/pam.d/common-session

session required pam_limits.so

Running ulimit -a is giving the below result:

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 15623
max locked memory (kbytes, -l) 16384
max memory size (kbytes, -m) unlimited
open files (-n) 200000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 200000
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

Below is the configuration in /etc/mosquitto/mosquitto.conf:

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

max_connections -1

log_type error
log_type warning
log_type notice

connection_messages true```

How to increase my mosquitto broker connection limits?
Please support us..

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu mosquitto Edit question
Assignee:
No assignee Edit question
Last query:
2020-10-19
Last reply:
2020-10-21
Bernard Stafford (bernard010) said : #1

On the manpages: Their is: $SYS/broker/clients/maximum
           The maximum number of clients that have been connected to the broker at the same time.
Then their is Total: $SYS/broker/clients/total
           The total number of active and inactive clients currently connected and registered on the broker.
Might check the value numbers.
http://manpages.ubuntu.com/manpages/bionic/man8/mosquitto.8.html
 All items support the values -1, unlimited or infinity indicating no limit, except for priority and nice.
   If a hard limit or soft limit of a resource is set to a valid value, but outside of the
       supported range of the local system, the system may reject the new limit or unexpected behavior may occur.
http://manpages.ubuntu.com/manpages/bionic/man5/limits.conf.5.html
The limit setting are set per login not global or permanent, exist only for the duration of the session.
<domain><type><item><value>
http://manpages.ubuntu.com/manpages/bionic/man8/pam_limits.8.html If Linux PAM is compiled with audit support the module
      will report when it denies access based on limit of maximum number of concurrent login sessions.
conf=/path/to/limits.conf
           Indicate an alternative limits.conf style configuration file to override the default.
I hope that this will help. It was all of the documentation that was relevant I could find. May have to override the default settings.

Can you help with this problem?

Provide an answer of your own, or ask mukilan for more information if necessary.

To post a message you must log in.