njh / mqtt-sn-tools

Command line tools written in C for the MQTT-SN (MQTT for Sensor Networks) protocol
MIT License
195 stars 84 forks source link

file descriptors / select issue with large number of clients #34

Open fgaultier opened 5 years ago

fgaultier commented 5 years ago

With a large number of clients (above 20), some subscribing clients do not receive any message. The issue is related with implementation of the mqtt_sn_select function in mqtt-sn.c file. Consider replacing line 817:

ret = select(sock + 1, &rfd, NULL, NULL, &tv);

with the following:

ret = select(FD_SETSIZE, &rfd, NULL, NULL, &tv);

We tested the change and it works fine

njh commented 4 years ago

Sorry for not responding to this.

I presume that select() takes a nfds parameter, and doesn't just default to the maximum allowed number of file descriptors, for performance issues.

However I am not sure why when using a large number of subscribing clients, it doesn't work for you. Are the clients and the server all on the same machine?