eclipse/paho.mqtt.c

long connection latency when setting up multiple mqtt connections

zhen9910 opened this issue · 0 comments

Description:
When setting up multiple connections using paho.mqtt.c library, the first connection is able to be set up very fast, about 200ms; but all the other connections are connected very slow, about 2s.

I first experienced this performance issue using paho.mqtt.rust v 0.12. eclipse/paho.mqtt.rust#217
As paho.mqtt.rust is a wrapper around paho.mqtt.c library, I can also reproduce this same perforamance issue using paho.mqtt.c.

So I want to ask if this is a known constraint or something that can be improved?

Reproduce:
This can be reproduced using attached sample code with paho-mqtt3a on Linux ubuntu 20.04.
mqtt_sample.txt

Log:

./build/mqtt_sample
====== Creating MQTT client ======
====== creating MQTT connect ======
====== Successful connection ====== 
====== Connect Time elpased is 204 ms ======

====== Creating MQTT client ======
====== creating MQTT connect ======
====== Successful connection ====== 
====== Connect Time elpased is 2105 ms ======

====== Creating MQTT client ======
====== creating MQTT connect ======
====== Successful connection ====== 
====== Connect Time elpased is 2106 ms ======

Trace:
Attached in trace.txt

trace.txt