mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-09 01:01:11 +08:00
mosquitto_pub: exit if broker actively refuses a connection
Fixes eclipse/mosquitto#1904 If the broker rejects the connection, as opposed to the broker being down, then there is no hope to establish a connection. This adds a status flag so we can signal to the loop that we should just exit. Signed-off-by: Dan White <dan.white@valpo.edu>
This commit is contained in:
parent
61702d7acc
commit
a65242d74a
@ -180,7 +180,8 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
|
||||
}else{
|
||||
err_printf(&cfg, "Connection error: %s\n", mosquitto_connack_string(result));
|
||||
}
|
||||
mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props);
|
||||
// let the loop know that this is an unrecoverable connection
|
||||
status = STATUS_NOHOPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -252,6 +253,10 @@ int pub_stdin_line_loop(struct mosquitto *mosq)
|
||||
#endif
|
||||
}
|
||||
|
||||
if(status == STATUS_NOHOPE){
|
||||
return MOSQ_ERR_CONN_REFUSED;
|
||||
}
|
||||
|
||||
if(status == STATUS_CONNACK_RECVD){
|
||||
pos = 0;
|
||||
read_len = line_buf_len;
|
||||
|
@ -21,6 +21,7 @@ Contributors:
|
||||
#define STATUS_WAITING 2
|
||||
#define STATUS_DISCONNECTING 3
|
||||
#define STATUS_DISCONNECTED 4
|
||||
#define STATUS_NOHOPE 5
|
||||
|
||||
extern int mid_sent;
|
||||
extern struct mosq_config cfg;
|
||||
|
Loading…
x
Reference in New Issue
Block a user