Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] C Client connection time is hardcoded to 100 mS

Hi Alexey,

it depends on the condition that the select is waiting for: if it is for TCP connection completed then the socket should be signalled and the select should break.

Ian

On 02/03/2017 08:14 PM, Alexey Sergeev wrote:
Hello,

Paho client is preferred MQTT client for our future project. But we have an issue with client connection time, it is more than 100 mS.  
We are 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, line 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 an intention to block the MQTTClient_connect method for 100 mS 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, could that be fixed in one of the next releases?

Thanks you very much.
Alexey



_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev

-- 
Ian Craggs                          
icraggs@xxxxxxxxxx                 IBM United Kingdom
Eclipse Paho Project Lead; Committer on Eclipse Mosquitto;
Tech Lead in IBM Watson IoT Platform


Back to the top