New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websockets performance is poor with mosquitto 2.x #2060
Comments
Do you get the same problems with libwebsockets 2.4.2? That's the most reliable version I have found. |
Ok I spent some time get mosquitto running with libwebsockets 2.4.2 but was not successful. I built libwebsockets 2.4.2 from source, and built and linked mosquitto (tried 1.6.12 and 2.0.6) against that libwebsockets. It runs, but fails to open the websocket. The following output was generated with
Curiously, the line So I'm afraid I am unable to test with libwebsockets 2.4.2 :-( |
My guess is that you are compiling against a later set of include headers, and because some public lws structs have been rearranged that is where the error is coming in. Anyway, I suspect that the real problem is that recent versions of libwebsockets disable the external poll support feature that mosquitto uses. You have to compile it yourself with that option turned on to get proper websockets support. Set |
I will try that. But still, why does mosquitto 1.6.12 work fine with libwebsockets 4.1.6 while the 2.x versions of mosquitto don't? Or is that external poll feature of libwebsockets only used in the 2.x versions of mosquitto? |
It's because in 2.0 a lot of optimisations were made so that for example mosquitto doesn't iterate over every client on each run of the network loop, to do various tasks, but is a lot more intelligent in when it does tasks. That means the external poll support (which was in use anyway, but wouldn't always be required for every operation) has to be correct. The optimisations aren't a huge factor at low client counts, but mean it's now possible to connect >1 million clients at once. |
I tried the docker version of 2.0.6 and that has no performance issues. I checked the Arch Linux package and they indeed build libwebsockets without So Thanks for the help! To avoid the same problem for others: Can Mosquitto detect if the used |
Good idea, that's done and in 2.0.7. |
If it is compiled without external poll support. Closes #2060. Thanks to Yannic Schröder.
Quick update: Bug report in Arch Linux: https://bugs.archlinux.org/task/70321 |
After upgrading from Mosquitto 1.6.12 to 2.0.6, the performance when sending/receiving large messages (multiple megabytes) via websockets is very poor.
I am working with
MQTT.js
version 4.2.1 and build Mosquitto withlibwebsockets
version 4.1.6.Tag
v1.6.12
does not show any performance issues, while tagv2.0.0
is very slow.v2.0.6
is very slow as well.I did a
git bisect
and it seems to be either commit 58aa41c or b91e783 that causes the issue. However, I cannot pinpoint it as I can't build mosquitto with some commits (some error inwebsockets.c
).@ralight in #1974 you mentioned that
mqttx
does some stupid stuff (that triggered that bug though).mqttx
also relies onMQTT.js
(same version 4.2.1 according to theirpackage.json
). So that stupid connection handling might also cause the performance issue I am seeing...The text was updated successfully, but these errors were encountered: