To enable Janus and Admin API of MQTT transport and change a log level, execute those commands from the project's directory (you must copy Dockerfile
and run-docker.sh
files there):
$ perl -pi -e 's/(enable = )no/${1}yes/' conf/janus.transport.mqtt.cfg.sample
$ perl -pi -e 's/(admin_enable = )no/${1}yes/' conf/janus.transport.mqtt.cfg.sample
$ perl -pi -e 's/(debug_level = )4/${1}6/' conf/janus.cfg.sample.in
Build and run the docker container
$ ./run-docker.sh
We could now build and run Janus Gateway in container's shell:
$ ./autogen.sh \
&& ./configure --prefix=/opt/janus --disable-rabbitmq \
&& make || true \
&& make -j $(nproc) \
&& make install \
&& make configs \
&& /opt/janus/bin/janus
Then, we could execute one more container's shell and publish MQTT message:
$ mosquitto_pub -h $(docker-machine ip) -t to-janus -m '{"janus": "create", "transaction": "1"}'
We would see the message in the log now:
MQTT client has been successfully connected to the broker
MQTT client has been successfully subscribed to MQTT topic: to-janus
Receiving Janus API message over MQTT: {"janus": "create", "transaction": "1"}
Got a Janus API request from janus.transport.mqtt (0x1d83320)
Transport task pool, serving request
Creating new session: 4788723488430663
Sending Janus API response to janus.transport.mqtt (0x1d83320)
Sending Janus API message via MQTT: {
"janus": "success",
"transaction": "1",
"data": {
"id": 4788723488430663
}
}
Update confugurations
## /etc/vernemq/vernemq.conf
listener.ssl.default = 0.0.0.0:8883
listener.ssl.cafile = /path/to/ssl/ex-ca.crt
listener.ssl.certfile = /path/to/ssl/ex.crt
listener.ssl.keyfile = /path/to/ssl/ex.key
## /opt/janus/etc/janus/janus.transport.mqtt.cfg
url = ssl://localhost:8883
ssl_enable = yes
cacertfile = /path/to/ex-ca.crt
certfile = /path/to/ex.crt
keyfile = /path/to/ex.key
Publish the message
$ mosquitto_pub -d -h $(docker-machine ip) -t to-janus -m '{"janus": "create", "transaction": "1"}' --cafile ssl/ex-ca.crt -p 8883 --insecure