mqtt-cli icon indicating copy to clipboard operation
mqtt-cli copied to clipboard

Exit code on fatal errors is incorrect

Open sbaier1 opened this issue 4 years ago • 2 comments

Expected behavior

Errors on basic operations like one-shot publishing lead to a corresponding exit code != 0, so i can use MQTT cli in scripts and assert proper exit codes.

Actual behavior

MQTT CLI always exits with code 0, even when connection to the broker fails completely

To Reproduce

Steps

Run a basic command like

java -jar mqtt-cli-1.1.2.jar pub -m "test" -h localhost -q 1 --topic test

when no broker is running, followed by a echo $? to check the exit code, which will be 0 even if the connection was refused and no publish was made.

Reproducer code

N/A

Details

  • Affected MQTT CLI version(s): 1.2.0
  • Used JVM version: java11

sbaier1 avatar Jun 18 '20 10:06 sbaier1

I have the same issue, I have a broker running locally (using docker-swarm). I manage to connect to the broker using the mqtt-cli (and the client connection is also visible from the broker web page). If I try to publish a message nothing happens: the message is not sent to the broker (I can see no logging even when TRACE level is enabled) and the returned code is 0 without any error. Is there at least somewhere where we can see the error from client side?

rbroggi avatar Feb 05 '22 18:02 rbroggi

With #308 we will refactor all commands to Callable, which should lead to all commands being assosciated with exit codes.

gitseti avatar Jul 21 '22 11:07 gitseti