in Freebsd mosquitto Websockets ~ read.

Installing Mosquitto with Websockets and Mosquitto-Auth-Plugin

Updated to reflect all issues with SSL and Websockets
See bottom of post.

Installing a version of mosquitto with websockets support And mosquitto-auth-plugin


pkg install mosquitto mysql57-client c-ares gmake libxslt python27 python2 c-ares cmake docbook-xsl openssl git  
cp /usr/local/openssl/openssl.cnf.sample /usr/local/openssl/openssl.cnf  

Compile and install Libwebsockets

cd /tmp

git clone  
git checkout v1.7-stable  
cd libwebsockets  
mkdir build  
cd build  
make install

Compile and install Custom Mosquitto

Remember if you upgrade mosquitto from pkg or rebuild you need to redo these steps since it will overwrite the custom mosquitto binary we build

cd /tmp  
git clone git://  
cd org.eclipse.mosquitto  
sed -i "" 's#WITH_WEBSOCKETS:=no#WITH_WEBSOCKETS:=yes#'  
sed -i "" 's#LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib#LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib -I/usr/local/include/#'  
sed -i "" 's#LIB_LDFLAGS:=${LDFLAGS}#LIB_LDFLAGS:=${LDFLAGS} -L/usr/local/lib/#'  
sed -i "" 's#BROKER_LIBS:=-lm#BROKER_LIBS:=-lm -L/usr/local/lib/#'  
sed -i "" 's#WITH_DOCS:=yes#WITH_DOCS:=no#'  
cp src/mosquitto /usr/local/sbin/mosquitto  
cp src/mosquitto_passwd /usr/local/sbin/mosquitto_passwd  
mkdir -p /var/lib/mosquitto/  
chmod 777 /var/lib/mosquitto/  
echo 'mosquitto_enable="YES"' >> /etc/rc.conf  

Compile and install Mosquitto-Auth-Plugin

cd /tmp  
git clone git://  
git clone git://  
cd mosquitto-auth-plug  
sed 's#MOSQUITTO_SRC =#MOSQUITTO_SRC = ../org.eclipse.mosquitto/#' >  
sed -i "" 's#BE_LDFLAGS =#BE_LDFLAGS = -L/usr/local/lib/#' Makefile  
cp /usr/local/lib/  
cp np /usr/local/sbin/  
chmod +x /usr/local/sbin/np  

Cleanup and removal of extra packages.

Make sure to not remove anything you need.

cd /tmp  
rm -rf libwebsockets  
rm -rf org.eclipse.mosquitto  
rm -rf mosquitto-auth-plug  
pkg remove git gmake libxslt cmake docbook-xsl  

Debug websockets

Add below to mosquitto.conf

log_type websockets  
websockets_log_level 255  


OpenSSL doesn't support ECDH  

You need openssl from port and setting the cmake flag -DLWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT=ON

comments powered by Disqus