Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retained messages are being dropped when connected via unix socket #3223

Open
Kiaatix opened this issue Feb 28, 2025 · 2 comments
Open

Retained messages are being dropped when connected via unix socket #3223

Kiaatix opened this issue Feb 28, 2025 · 2 comments
Labels
Status: Available No one has claimed responsibility for resolving this issue.

Comments

@Kiaatix
Copy link

Kiaatix commented Feb 28, 2025

Mosquitto doesn't deliver all retained messages when connected via unix socket.

Tested with Mosquitto 2.0.20 with config

listener 1883
listener 0 /tmp/mosquitto.sock

Publish 5000 retained messages:

#!/bin/bash
for i in {1..5000}
do
    mosquitto_pub -t "test/$i/testmsg" -m "test $i" --retain
done

Connection over TCP works as expected:
mosquitto_sub -h 127.0.0.1 -t "test/#"
Output:

test 1
test 2
.
.
.
test 5000

But with
mosquitto_sub --unix /tmp/mosquitto.sock -t "test/#"
Output:

test 1
test 2
.
.
.
test 1462

with mosquitto.log entry
Outgoing messages are being dropped for client auto-C7D5C72D-ECFE-F6F4-AB79-0FDAC37A8969.

There should be no difference in message handling between connection types.

@github-actions github-actions bot added the Status: Available No one has claimed responsibility for resolving this issue. label Feb 28, 2025
@sikmir
Copy link

sikmir commented Feb 28, 2025

Can't reproduce with 2.0.20.

@Kiaatix
Copy link
Author

Kiaatix commented Feb 28, 2025

The problem only exists when connecting/subscribing after the messages have been published, i.e. when the broker delivers the retained messages. When the client is already subscribed while publishing, it works normally.

I was able to reproduce it on a Ubuntu 22.04 machine with mosquitto 2.0.11, on Ubuntu 24.04 with mosquitto 2.0.18 and still experiencing it with 2.0.20 from mosquitto-ppa on a fresh Ubuntu 24.04 VM.

My active config is:

persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
listener 1883
listener 0 /tmp/mosquitto.sock
allow_anonymous true

After publishing the messages, I connect mosquitto_sub over TCP and everything is delivered as expected with log:

1740761663: New connection from 127.0.0.1:40418 on port 1883.
1740761663: New client connected from 127.0.0.1:40418 as auto-5644E03B-6044-F541-7F7F-8901E2E4B862 (p2, c1, k60).
1740761665: Client auto-5644E03B-6044-F541-7F7F-8901E2E4B862 disconnected.

Then, when connectiong over unix socket, I'm receiving only ~1500 of the retained messages with log:

1740761680: New connection from /tmp/mosquitto.sock:0 on port 0.
1740761680: New client connected from /tmp/mosquitto.sock:0 as auto-D299BB41-637E-6CFC-1FDF-2717F9681972 (p2, c1, k60).
1740761680: Outgoing messages are being dropped for client auto-D299BB41-637E-6CFC-1FDF-2717F9681972.
1740761682: Client auto-D299BB41-637E-6CFC-1FDF-2717F9681972 disconnected

When i set max_queued_messages 6000, it works as expected, but as far as I know, message queuing only applies to QoS 1+2 and not for retained messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Available No one has claimed responsibility for resolving this issue.
Projects
None yet
Development

No branches or pull requests

2 participants