1

I have single line in Mosquitto ACL file:

pattern read write s2

I'm trying to post to s2 :

mosquitto_pub -h 192.168.1.8 -t s2 --cafile ca.crt -m "test" -p 8883 -d -u b -P b -i b

Got results in Mosquitto and client consoles below.

Mosquitto:

1577876055: New connection from 192.168.1.222 on port 8883.
1577876055: New client connected from 192.168.1.222 as b (c1, k60, ub).
1577876055: Sending CONNACK to b (0)
1577876055: Denied PUBLISH from b (d0, q0, r0, m0, 's2', ... (4 bytes))
1577876055: Received DISCONNECT from b

Client:

Client b sending CONNECT
Client b received CONNACK
Client b sending PUBLISH (d0, q0, r0, m1, 's2', ... (4 bytes))
Client b sending DISCONNECT

Then I did subscription to s2 :

mosquitto_sub -h 192.168.1.8 -t s2 --cafile ca.crt -p 8883 -d -u b -P b

And tried again the same publishing:

mosquitto_pub -h 192.168.1.8 -t s2 --cafile ca.crt -m "test" -p 8883 -d -u b -P b -i b

Now Mosquitto rejects my publishing:

Mosquitto:

1577876215: New connection from 192.168.1.222 on port 8883.
1577876215: New client connected from 192.168.1.222 as b (c1, k60, ub).
1577876215: Sending CONNACK to b (0)
1577876215: Denied PUBLISH from b (d0, q0, r0, m0, 's2', ... (4 bytes))
1577876215: Received DISCONNECT from b

Client:

Client b sending CONNECT
Client b received CONNACK
Client b sending PUBLISH (d0, q0, r0, m1, 's2', ... (4 bytes))
Client b sending DISCONNECT

Now Mosquitto reports Denied PUBLISH. Why it denieds publishing only when there are active subscribers?

What is wrong with ACL record? Why I can't publish and subscribe at all?

  • 2
    Edit the question to show the whole ACL file. If it just contains that one line then that rule will only be used for anonymous users. Also pattern expects substitution wildcards. – hardillb Jan 1 at 13:01
  • 1
    Also there should be no space between read and write – hardillb Jan 1 at 16:29
  • 1
    In case I omit space between read write I will get error in Mosquitto server ` Empty invalid topic access type in acl_file.` – vico Jan 1 at 17:28
  • 1
    That's because your pattern doesn't contain a %u or %c (it should be a topic entry) – hardillb Jan 1 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.