If CONNACK packet's state code is non-zero,loop will not stop and try to reconnect many a time
Today i want to test password is wrong this case and find that client always try to reconnect.
In read_handle_client.c
switch(result){
case 0:
mosq->state = mosq_cs_connected;
return MOSQ_ERR_SUCCESS;
case 1:
case 2:
case 3:
case 4:
case 5:
return MOSQ_ERR_CONN_REFUSED;
default:
return MOSQ_ERR_PROTOCOL;
}
If result is non-zero we don't modify mosq->state. In mosquitto_loop_forever mosquitto will call mosquitto_reconnect many a time to reconnect.
Should we modify mosq->state if CONNECT fail?
What version do you have this issue?
In Last version mosquitto_loop_forever will check mosquitto_loop return value. The loop will quit if error is fatal. But MOSQ_ERR_CONN_REFUSED is not deemed to a fatal error, loop will continue and reconnect again.
What i want to ask is should client stop reconnect server and quit loop if CONNECT fail.
Thanks advance :)