eclipse-paho / eclipse-paho/paho.mqtt.python
Unable to make 340 connections
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 742
- Avg merge
- 12d 48m
- Merged PRs (30d)
- 1
Description
Hi Everyone,
I've been hitting my head against the wall because I can't make more than 340 connections to a local vernemq server and I have no idea why. I created a simple script to to try to make 350 connections but CONNACKs are not received after the first 340 connections are made.
I have not received the connection limit on my local machine because if I run two instance a total of 680 (340 x 2) connections are established.
Is anyone aware of this bizarre limit ?
PS. My goal is to use this client with locustio for load testing.
My setup
- python 3.6.0
- maximum number of file descriptors, 65536
- local vernemq allows anonymous connections
- vernemq has all other defaults enabled
_test_paho.py_
```
import paho.mqtt.client as mqtt
import threading
connect_count = 0
lock = threading.Lock()
def locust_on_connect(client, flags_dict, userdata, rc):
global lock
global connect_count
print(f"client: {client} connected, rc: {rc}")
lock.acquire()
connect_count += 1
print(f"connect_count: {connect_count}")
lock.release()
def locust_on_subscribe(client, userdata, mid, granted_qos):
print(f"client: {client} subscribed, mid: {mid}")
def log(client, userdata, level, buf):
print(f"[paho-log][client: {client}] {buf}")
for x in range(0, 350):
client = mqtt.Client(transport="websockets")
host = localhost #
port = 8888 #
client.on_connect = locust_on_connect
client.connect_async(host, port)
client.loop_start()
client.subscribe("/topic", 1)
input("type enter to end")
```
_last few lines of output_
```
connect_count: 339
connect_count: 340
```
Any help is greatly appreicated.
Contributor guide
Assessment
This issue has not been assessed yet.