Reputation: 6613
Has anybody successfully run mosquitto on the openshift online version in a free account?
There are two SO questions relevant but not really solve all the questions:
Stuffs that have been done so far:
What is the exact steps to put mosquitto to run on the openshift from here?
Upvotes: 0
Views: 1617
Reputation: 944
In case anyone else runs across this post; I have a non-websocket Mosquitto running on OpenShift v3.11: https://github.com/john2exonets/OpenShift-MQTT-Mosquitto
Upvotes: 1
Reputation: 6613
Finally I got it working on openshift, though with a simplest configuration. Here is the key steps:
DIY
cartridge to get the websocket support which exposes external port 8000
and that is routed to internal port 8080
on an virtual IP address specified by OPENSHIFT_DIY_IP
.config.mk
just to avoid installing lot of packages to openshift: WITH_TLS
, WITH_TLS_PSK
, WITH_THREADING
, WITH_BRIDGE
, WITH_SRV
, WITH_UUID
, WITH_DOCS
, WITH_SOCKS
. Makefile
of mosquitto to comment out the command to install from DOCSDIR
. This seems to be a minor bug in mosquitto because if the WITH_DOCS
is turned off it should not try to install from DOCSDIR
. WITH_WEBSOCKETS
in config.mk
. src/webockets.c
. In the function mosq_websockets_init()
at about line 625, add a line of info.iface = listener->host;
, below the line which is info.user = user;
. This is to make mosquitto able to bind to the virtual IP address in the openshift DIY gear. By default mosquitto only allow you to bind to 0.0.0.0
for any IP address. This seems to be a disconnection between mosquitto and libwebosockets. libwebsockets
and libwebsockets-devel
packages. make
to build mosquitto. ../mosrun
directory. Create the directory. Run make prefix= DESTDIR=$(pwd)/../mosrun install
. ../mosrun
except sbin
. cd ../mosrun/sbin
and cp /usr/lib/libwebsockets.so.7 .
. Adjust the source path of your stock libwebsockets lib. https://github.com/jpmens/simple-mqtt-websocket-example
. Put them into your mosrun/sbin/simpleweb
directory. mosrun/sbin/simpleweb/config.js
to use your openshift DIY domain name, and port 8000. This is where the javascript connects to your DIY server from a browser. mosrun/sbin/mosquitto.conf
which contains four lines: listener 8080 <OPENSHIFT_DIY_IP>
, protocol websockets
, http_dir simpleweb
, and connection_messages
. Use your actual DIY virtual IP address in place of <OPENSHIFT_DIY_OP>
. .openshift/action_hooks/start
and .../stop
scripts to comment out the existing commands. Push to openshift. Now you should not be able to connect to the default server but the gear is running. mosrun/sbin
directory. LD_LIBRARY_PATH=. ./mosquitto -c mosquitto.conf -v
to start mosquitto. diy-yourdomain.rhcloud.com:8000/index.html
. You shall see the mqtt websockets test page copied from jpmen's github repo. The next step would be to move the tree into DIY git tree. Modify the start and stop hooks to start and stop your mosquitto instead of the default server. And a script running on the openshift gear to create the config.js
and mosquitto.conf
from the actual openshift environment variables.
Tow posts are very helpful to guide you through the steps of building mosquitto: the blog by jpman, and the blog by Jeremy Gooch.
Upvotes: 1