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

Prerequisits

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 https://github.com/warmcat/libwebsockets.git  
git checkout v1.7-stable  
cd libwebsockets  
mkdir build  
cd build  
cmake .. -DLWS_WITHOUT_TESTAPPS=ON -DLWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT=ON  
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://git.eclipse.org/gitroot/mosquitto/org.eclipse.mosquitto.git  
cd org.eclipse.mosquitto  
sed -i "" 's#WITH_WEBSOCKETS:=no#WITH_WEBSOCKETS:=yes#' config.mk  
sed -i "" 's#LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib#LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib -I/usr/local/include/#' config.mk  
sed -i "" 's#LIB_LDFLAGS:=${LDFLAGS}#LIB_LDFLAGS:=${LDFLAGS} -L/usr/local/lib/#' config.mk  
sed -i "" 's#BROKER_LIBS:=-lm#BROKER_LIBS:=-lm -L/usr/local/lib/#' config.mk  
sed -i "" 's#WITH_DOCS:=yes#WITH_DOCS:=no#' config.mk  
gmake  
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.eclipse.org/gitroot/mosquitto/org.eclipse.mosquitto.git  
git clone git://github.com/jpmens/mosquitto-auth-plug.git  
cd mosquitto-auth-plug  
sed 's#MOSQUITTO_SRC =#MOSQUITTO_SRC = ../org.eclipse.mosquitto/#' config.mk.in > config.mk  
sed -i "" 's#BE_LDFLAGS =#BE_LDFLAGS = -L/usr/local/lib/#' Makefile  
gmake  
cp auth-plug.so /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  

Errors:

OpenSSL doesn't support ECDH  
SSL disabled: no LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT  

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

comments powered by Disqus