Mosquitto (MQTT) - Client connection from [ip address] denied access by tcpd

Hi All,

Referring to this post, which is closed now: MQTT "close timeout" issue using Aedes - #14 by Steve-Mcl

I've had a few instances over the past two days where NR has stopped working as expected.

I've done restarts and it's gone back to "normal", however when it happened for the 3rd time today, I had to dig deeper.

The issue appears to relate to MQTT messages not being sent/received, so I decided to check the mosquitto log, using this command (thank you to @Colin for sharing that command in the previous post, above):

sudo tail -f /var/log/mosquitto/mosquitto.log

To find an error message that is being reported through my searches to related to too many open files, presumably above the 1024 limit.

I have found a few articles on how to fix it (a couple cited below), but as is the case, they advise different methods to resolve the issue:

I am hoping there is someone on the forum that knows the "best" way to do this, else I'll do some more research and go down the trial and error path.

Thanks in advance for any help!

EDIT: I've had a go and added the following line to /usr/lib/systemd/system/mosquitto.service:

[Service]
LimitNOFILE=49152

then ran these...

sudo systemctl daemon-reload
sudo service  mosquitto stop
sudo service  mosquitto start

I just ran this after a restart to see the count of open connections:

sudo netstat -natp | grep ESTABLISHED.*mosquitto | wc -l

The count was 348. I will keep an eye on it, now that I know to run the command and see if it goes over 1,024, in which case the issue was related to the max number of open files.

Would still appreciate a steer if I'm headed down the wrong path

Cheers

I had problems with Mosquitto as well. My shellies did not report mqtt messages any more. I tried many things but it did not work. Finaly I found a report at stackoverflow:
sudo service mosquitto stop
sudo rm /var/lib/mosquitto/mosquitto.db
sudo service mosquitto start
after I did this all worked perfectly again :slight_smile:

1 Like

Hey @juntiedt, that's interesting. It implies there was an error in the mosquitto db.

I'll back up the db, in case, and try out your suggestion in a week or so (if mqtt stops working again). I want to first let my last change settle in.

I haven't done anything on the system since earlier today, but the count of open files is still sitting at 348, which is a bit odd... maybe I'll have to try out your suggestion. let's see.

@juntiedt

I spoke too soon.

It happened again i.e. in my case, a complete system malfunction. Still only 348 connections.

I've tried out your suggestion :crossed_fingers:

If it doesn't work, I'm up the proverbial without a paddle....

Hmm, I wonder what you are doing. My live home automation system shows 8 connections only.

Presumably you must have a lot of directly connected devices? Are they perhaps sometimes disconnecting and not restarting with a clean session?

Oh, I forgot, I've still got 5 other connections on my old Pi2 broker. That is bridged to my live server. Thought 8 seemed a bit low :smile_cat:

What version of Mosquitto do you have installed?

@TotallyInformation

Yes, lots of individual devices on my flows. When I looked into mqtt it seemed to be setup for volume, so rather than create centralised conduits for data transmission, I spilt it out.

It really works very well, barring the recent issue. Performance is great.

No, they don't randomly or otherwise disconnect. The entire mqtt service fails.

I think the suggestion above has fixed it... Fingers crossed.

post moved to a new thread here: MQTT open files increasing on "Restart Flows"

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.