|C client connection time [message #1753321]
||Fri, 03 February 2017 20:03
| Alexey Sergeev
Registered: January 2017
Paho client is preferred MQTT client library for our future project. But we have an issue with client connection time. We are in favor of using C paho client library.
We know the root cause of the issue.
While connecting (MQTTClient_connect method) the client uses MQTTClient_waitfor method to check if the socket is ready for writing:
MQTTClient.c, line 826
MQTTClient_waitfor(handle, CONNECT, &rc, millisecsTimeout - MQTTClient_elapsed(start));
The MQTTClient_waitfor method in turn executes MQTTClient_cycle with a hard-coded delay:
MQTTClient.c, line 1682:
pack = MQTTClient_cycle(&sock, 100L, rc);
The delay is used as a timeout parameter for the select method waiting for any socket ready for reading data:
Socket.c, loine 241:
select(s.maxfdp1, &(s.rset), &pwset, NULL, &timeout)
The problem is that as soon as we are still connecting there are no any incoming messages so there is no data to read and the select method gets blocked for the specified timeout which is 100 mS.
As a result MQTTClient_connect method runs for more than 100 mS.
I wonder was there in intention to block the MQTTClient_connect method or that is a bug? Without the hard-coded timeout the connection time can be reduced to a 0.5 mS.
If that is a bug, can that be fixed in one of the next releases?
Thanks you very much.
Powered by FUDForum
. Page generated in 0.02660 seconds