Skip to content

Commit

Permalink
* TEST Fixed backoff and fixed clientid.
Browse files Browse the repository at this point in the history
Signed-off-by: wanghaemq <[email protected]>
  • Loading branch information
wanghaEMQ committed Sep 10, 2024
1 parent 811dea6 commit 4df2c07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions demo/mqtt/mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ client_connect(
connmsg, (uint8_t *) "bye-bye", strlen("bye-bye"));
nng_mqtt_msg_set_connect_will_topic(connmsg, "will_topic");
nng_mqtt_msg_set_connect_clean_session(connmsg, true);
nng_mqtt_msg_set_connect_client_id(connmsg, "nanosdk-client-id");

nng_mqtt_set_connect_cb(*sock, connect_cb, sock);
nng_mqtt_set_disconnect_cb(*sock, disconnect_cb, connmsg);
Expand Down
6 changes: 6 additions & 0 deletions src/mqtt/transport/tcp/mqtt_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1553,15 +1553,21 @@ mqtt_tcptran_ep_connect(void *arg, nni_aio *aio)
if (nni_aio_begin(aio) != 0) {
return;
}

ep->backoff = 1000;
nni_msleep(ep->backoff);
/*
if (ep->backoff != 0) {
ep->backoff = ep->backoff * 2;
ep->backoff = ep->backoff > ep->backoff_max
? (nni_duration) (nni_random() % 1000)
: ep->backoff;
ep->backoff = ep->backoff * 2;
nni_msleep(ep->backoff);
} else {
ep->backoff = nni_random()%2000;
}
*/
nni_mtx_lock(&ep->mtx);
if (ep->closed) {
nni_mtx_unlock(&ep->mtx);
Expand Down

0 comments on commit 4df2c07

Please sign in to comment.