-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Segfault using Mosquitto websockets #303
Comments
It looks like you're using an authentication plugin, could you provide details of what that is? |
We use JPMens's auth plugin.
|
I just learned that our one javascript websocket client was actually many, in different browser tabs, all with the same clientid. That probably accounted for the many reconnects (because the clientid wasn't unique), which seem to be related to the problem. But, it's not the root trigger; there was also a confirmed crash with one client, but it did take a long time for it to crash that time. |
Ah, thanks that's very useful. You're saying that the crash occurred when it was only a single WS client connected and it was definitely not multiple clients sharing the same ID? |
Yes, but it took a whole evening, as the frontend dev in question reported. The other case takes 1-10 mins, repeatedly. |
I think I found the cause of the crash. I analyzed the core dump, and found the following: The
Then in
The
So, the callback is called with non-existing fields in the struct. Didn't even know the compiler didn't break on that... It was introduced with libwebsocket 1.6 support. (edit: we were just able to reproduce it with a client) |
Apparently the cause is the compatability macros like Fix?:
|
Actually, the compatability macro's are fine; that's why GCC approved it too. I was able to crash it numerous times at different locations, but all of them are on |
As I said on #319: I have really struggled to reproduce this but have now been able to do it consistently. It looks as though the problem is related to the libwebsockets binary in ubuntu. I couldn't reproduce it at first because I had a separate version of libwebsockets (1.7.x) installed not from ubuntu. Even recompiling the version which is in ubuntu myself doesn't result in any crashes. I'm not really sure what the general solution is here, it seems a bit out of my control. Could you try compiling your own version of libwebsockets though? |
I reported an Ubuntu bug. On our production server, I just use Websockify in front of Mosquitto |
I got similar problem with mosquitto in Ubuntu 16.04.1 LTS. traps: mosquitto[1012] general protection ip:7f7e8536ba0c sp:7ffd4817ea70 error:0 in libwebsockets.so.7[7f7e85363000+1f000] |
@hillkim7 you should comment on the bug report at Ubuntu I linked to above. |
Out of interest could you try again with the new 1.4.11? |
I got two mosquitto servers having problem with the libwebsockets.so. |
I think we should keep replying to that Ubuntu bug I submitted. Canonical is far too lax when it comes to fixing bugs, in my opinion. |
The mosquitto halt problem still exists with 1.4.11 mosquitton. |
For me, mosquitto is also crashing when using websockets. One normal publisher / subscriber and one publisher / subscriber with websockets is enough to get i crashing. Can someone explain the Websockify workaround or push me in the right direction? Or is there another solution? |
Just Google websocikfy. It's a wrapper you can start that serves any TCP socket as websocket. |
For me, it wasn't easy to utilize websockfy for MQTT web access. |
In that case, you may just want to uninstall Mosquitto and libwebsockets7, take the most recent Mosquitto deb file, and obtain the libwebsockets3 from a current Debian jessie mirror if you run Ubuntu (because the mosquitto deb file has a dependency on libwebsockets3 and Ubuntu 16.04 at least doesn't have it). I suspect that will work fine, because then you have a recent mosquitto, with a libwebsockets that has been used during development. I actually already set up our server like this, but our websocket MQTT project is on hold. When I'll get back to it again, I'll check if Mosquitto works without Websockify this way. |
I have faced this bug some time ago. Ubuntu 16.04, mosquitto 1.4.8 and libwebsockets 1.7.1. mosquitto process crashed restarted several times per day. Segfault in logs. Then, I recompile libwebsockets 1.7.8 from sources (it is the last version with same filename with 1.7.1) and substitute compiled library on place. No crash in two weeks. |
I could easily reproduce it with Ubuntu 16.04, mosquitto 1.4.8 and libwebsockets 1.7.1 by refreshing browser a lot. Instead of building libwebsockets, I just updated mosquitto to 1.4.14. |
As I understand from forums, since 1.4.12 libwebsockets problems are gone. I've the same problem with 1.4.10 and I'll try the 1.4.14 on Ubuntu 16.04. |
I am sorry to bring bad news. The segmentation fault problem is still lingering on Ubunto 16.04.
Today I got mosquitto dead couple of times while I was testing my web app that use the MQTT through websocket. |
Over two month still have no crashes with mosquitto 1.4.8 and libwebsockets 1.7.8 on Ubuntu 16.04. |
My config is OK : |
@hillkim7 Are you able to reproduce it? |
@ralight Probably.. I'll let you know if I reproduce it. |
https://libwebsockets.org/abi/timeline/libwebsockets/index.html has the SO version for each release. |
libwebsockets v2.4 released 2017-10-16 with soname .12 |
The version of my libwebsockets is like following:
This is default websocket package that Ubuntu 16.04 provides. |
It's OK for you @hillkim7 ? |
@Tifaifai if I follow your instructions, will mosquitto automatically use the correct I have used your instructions for websockets 1.7.8 (I have put the corresponding files within However when I run the following command: I get the following output (for websockets):
Making me think that mosquitto isn't using the correct library? My understanding is that the binary should be using I am running Xenial (Ubuntu 16.04.2) |
Hi,
|
I tried with libwebsockets v2.4.1 and haven't seen an issue in the last couple of days. |
In my testing I can occasionally get crashes to occur using lws 1.7.1, but haven't been able to track down the cause of the problem. With 2.4.1 I have seen no crashes. I think the problem is with libwebsockets. |
Using mosquitto (1.4.15) provided with Ubuntu 18.04 LTS, crashes on each tls websocket connect attempt:
Using websockets without tls seems to work so far. |
'Regression in libwebsockets 2.1.0 - unable to connect to mosquitto via websocket #774' warmcat/libwebsockets#774 Update your libwebsockets with minimum 2.4.1 version. |
@Tifaifai |
Félicitations ;) It's a good pratice ;) |
@Tifaifai Please, could you explay how to upgrade to?:
I have follow your instructions but have same problem as @WilliamHua, mosquitto continues using libwebsockets.so.7: |
You can use v2.4.2 : and maybe type |
Updating libwebsocket solves the problem indeed! v2.4.2 compiled and installed from source. |
It seems like moving to libwebsockets 2.4.2 works for a lot of people, so I'm closing this issue. |
Using Mosquitto 1.4.10 (and 1.4.8), we get segfaults when a websocket client has been running for a while. The segfault seems to orinate in libwebsockets 1.7 (shipped with Ubuntu 16.04), but but because it's running a callback function, it may actually be Mosquitto. I tried using the newest libwebsockets 2.1 stable, but then it crashes on handshake.
Perhaps related, there is a fair amount of SIGPIPE broken pipe signals for which I see no apparent reason. We can reproduce this with many TCP clients and one websocket client. There doesn't seem to be a good reason why that websocket client keeps losing its connection. Additionally, before the stack trace, it always seems to have done authentication with HTTP (
http:https://127.0.0.1:80/auth/
). The current client is programmed to reconnect after a broken connection, so it appears as though the sequence is disconnect-reconnect-auth-crash.See below for a stack trace when running Mosquitto 1.4.10 with libwebsockets 1.7.
A core dump is also available, but that probably does contain sensitive information, because we could only reproduce this issue on our live server with enough traffic.
The text was updated successfully, but these errors were encountered: