Comentários (11)

1 pdominique comentou às Link permanente

Hi Dom,

Thanks for sharing these instructions, this is exactly what I wanted to do. I followed the instructions to install lighttpd + mod_websocket on my Raspberry Pi model B with the latest Raspian (installed via NOOBS) and I believe everything was installed properly. However I get the following error when I try to connect using the Paho JS library: AMQJS0016E Invalid MQTT message type 0. Here's the output in Mosquitto:
1392675175: New connection from on port 1883.
1392675175: New client connected from as myclientid_ (c1, k60).
1392675175: Sending CONNACK to myclientid_ (0)
1392675188: Socket read error on client myclientid_, disconnecting.
Could you tell me what version of Raspbian, Mosquitto etc. you are using?

2 BRAMLEYD comentou às Link permanente

HI Pierre, not sure of the versions as I don't have access to the pi right now. But they were the latest available at the time using apt-get update

I would double check that the websocket.conf file is correct, that it is being passed correctly to lighttpd and that it is being run as root. Looking at the start instruction above it doesn't specify the path to websocket.conf - so it may be worth running it from /home/pi/lighttpd1.4 to see if that improves matters.
Lastly what client are you testing with? : I found the client works well. Specify the ip of the pi as <ipaddress>/mqtt
port : 80.</ipaddress>

3 pdominique comentou às Link permanente

I double checked everything but I can't find the issue. This might be a problem related to our proxy, this would not be the first time... I just installed another broker with native web socket support (HiveMQ) to do a quick test and it works just fine with the IBM mqtt client ( However it doesn't work with HiveMQ mqtt client for some reason (

4 pdominique comentou às Link permanente

Hi Dom, I just had to change "type" => "bin" to "type" => "binary" in the config file and now everything seems to work as expected! I found this information on the mod_websocket Github repo: and Thanks for you help.

5 BRAMLEYD comentou às Link permanente

Ah, good find Pierre! I have updated the sample file in the post.

Glad you got it working!

6 Lieven Merckx comentou às Link permanente

Hi Dom,

thanks for documenting this. It helped a lot.
Just noticed that I had some difficulties deploying mqttws31.js on the raspberry. I published it under http://server/mqttws31.js and the browser couldn't download it. Renaming to ws31.js makes it work.
I guess the websocket interception /mqtt is playing a role in this. I need to do some more investigation.

7 SimpleE comentou às Link permanente

I tried all the steps above but i get this error

$ sudo lighttpd -D -f websocket.conf
2014-07-30 13:17:58: (plugin.c.169) dlopen() failed for: /usr/local/lib/ /usr/local/lib/ cannot open shared object file: No such file or directory
2014-07-30 13:17:58: (server.c.679) loading plugins finally failed

8 PeteWozzzz comentou às Link permanente

SimpleE. I had exactly the same problem with
"$ sudo lighttpd -D -f websocket.conf
2014-07-30 13:17:58: (plugin.c.169) dlopen() failed for: /usr/local/lib/ /usr/local/lib/ cannot open shared object file: No such file or directory
2014-07-30 13:17:58: (server.c.679) loading plugins finally failed"

The problem is that /usr/local/lib/ file does not exist on your system. The final step 'sudo make install' did not copy the right files to the right locations and hence it cannot find the relevant file. In my case I messed up the installation by going with the latest version (git checkout lighttpd-1.4.35), rather than with 1.4.33. Everything seemed fine until 'make install', which resulted in the following:
patch the lighttpd sources
Target Lighttpd version: lighttpd-1.4.32
do patch? [y/n]
Originally I said 'y' and this thrown some errors (for lighttpd1.4.35). Therefore I did 'make install' again but this time said 'no'. This seemed to work. I managed to carry on with the other installation steps but when trying to run lighttpd I had the same error as you. To fix this I went with lighttpd 1.4.33 as in the instructions and answering 'yes' to 'make install' did not throw any exceptions. Then I noticed that in the final step 'sudo make install' files do get copied to '/usr/local/lib/' and other relevant locations. I hope this helps

9 BRAMLEYD comentou às Link permanente

Thanks for that Pete :0

Another possible option now - is that I believe that the latest build of Mosquitto has Web Socket support. I've not investigated how to enable it yet.
But if this can be done for the Pi then it would do away with the need for all this hacking around with Lighttpd .... (and render this post obsolete :0) )

10 PeteWozzzz comentou às Link permanente

After all this effort my MQTT broker is malfunctioning. In Node-Red I can no longer see messages being sent and received. When I use a Java program to connect to the broker, it connects ok but does not receive any messages on a given topic. However, the little Java app is able to publish to the broker and receive it's own published data.

Do I need to re-install Mosquitto? Do websockets need to be install prior to Mosquitto installation? Why installing websockets somehow stopped the broker from successfully publishing?
When I use a Paho JS, on connecting I get an error about "Connection failed: AMQJSC0001E Connect timed out.". In the JS code I tried various configuration. I give it my IP address and port 80. Any pointers as to what to do and why mqtt is working differently after installing lighttpd?

11 PeteWozzzz comentou às Link permanente

No worries. It's all working now. I have restarted my Raspberry Pi couple of times and when it wasn't working I left it aside. When I switched it on, I could see debugging info flowing from Node-Red's mqtt stream. It might have been my networking settings which I changed from dynamic to static IP (needed dynamic to connect Internet to it, and now need it with static IP). Not sure what went wrong, but Paho JS can now connect and print messages from Raspberry Pi's mqtt broker on port 80.