Improved ACLK reconnection sequence (#8708)
* Change aclk_connecting to a counter and attempt to reconnect in case the LWS layer is not responding (no callbacks received) Do not attempt subscription if we are not connected * Set aclk_connecting before calling the MQTT / LWS layer
Stelios Fragkakis committed
Apr 15, 2020 at 21:37 UTC
853b23745e7df2f163df1c0213c9de52394de36b
1 file changed
+3
-1
aclk/agent_cloud_link.c
+3
-1
@@ -1257,11 +1257,11 @@ static void aclk_try_to_connect(char *hostname, char *port, int port_num)
1257
if (aclk_password == NULL)
1258
return;
1259
int rc;
1260
+ aclk_connecting = 1;
1261
rc = mqtt_attempt_connection(hostname, port_num, aclk_username, aclk_password);
1262
if (unlikely(rc)) {
1263
error("Failed to initialize the agent cloud link library");
1264
}
1264
- aclk_connecting = 1;
1265
}
1266
1267
@@ -1355,6 +1355,8 @@ void *aclk_main(void *ptr)
1355
}
1356
1357
_link_event_loop();
1358
+ if (unlikely(!aclk_connected))
1359
+ continue;
1360
/*static int stress_counter = 0;
1361
if (write_q_bytes==0 && stress_counter ++ >5)
1362
{