mosquitto
mosquitto copied to clipboard
mosquitto_pub does not return error exit code when connection fails
Hi all,
mosquitto_pub in version 1.4.10 returned exit code 5 when a connection to Mosquitto was not allowed (e.g. after adding allow_anonymous false to mosquitto.conf):
# mosquitto_pub --debug -h mosquitto -t test -m test
Client mosqpub/6-b4743bf10343 sending CONNECT
Client mosqpub/6-b4743bf10343 received CONNACK
Connection Refused: not authorised.
Error: The connection was refused.
# echo $?
5
In version 1.6.2 mosquitto_pub returns exit code 0 in the same case:
# mosquitto_pub --debug -h mosquitto -t test -m test
Client mosq/sFqMxtgqkw9lpHaaCn sending CONNECT
Client mosq/sFqMxtgqkw9lpHaaCn received CONNACK (5)
Connection Refused: not authorised.
# echo $?
0
Is that a bug or was a deliberate design decision made to change the behaviour? I could not find anything in the mosquitto_pub docs about exit codes.
Thanks in advance for your feedback and best regards
Jannis
This wasn't deliberate, thanks for reporting it. I've just pushed a change that fixes it and it will be in 1.6.3.