MQTT 协议相关

Summary: Author: 张亚飞 | 阅读时间: 2 minute read | Published: 2015-09-23
Filed under Categories: LinuxTags: Note,

MQTT 协议相关

MQTT 服务器

使用 emqttd broken

emqttd 使用以下命令调试输出

/opt/data/

wget http://emqtt.com/static/brokers/emqttd-ubuntu16.04-v2.0.2.zip
unzip emqttd-ubuntu16.04-v2.0.2.zip
cd emqttd
./bin/emqttd console

如果没有打印输出日志信息,可以参考取消 rel/files/emqttd.config.production./etc/emqttd.config 中对 %%{lager_console_backend, info} 的注释


EMQ Dashboard 后台证书配置

编辑配置 etc/plugins/emq_dashboard.confwss 相应的域名证书:

dashboard.listener.https = 18084
dashboard.listener.https.acceptors = 2
dashboard.listener.https.max_clients = 512
dashboard.listener.https.access.1 = allow all
dashboard.listener.https.keyfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/privkey.pem
dashboard.listener.https.certfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/cert.pem

重启访问测试:

http://103.37.147.250:18083/#/websocket
https://mus.0.sw.iirii.com:18084/#/websocket

EMQ WSS 证书配置

编辑配置 etc/emq.confwss 相应的域名证书:

#listener.wss.external.keyfile = etc/certs/key.pem
listener.wss.external.keyfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/privkey.pem

#listener.wss.external.certfile = etc/certs/cert.pem
listener.wss.external.certfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/cert.pem

## listener.wss.external.cacertfile = etc/certs/cacert.pem
listener.wss.external.cacertfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/ca.pem

使用后台 wss 连接测试

使用 mqtt.js 连接测试

// you add a ws:// url here
var client = mqtt.connect('wss://mus.0.sw.iirii.com:8084/mqtt');

注意: Android 配置连接方式 wss 需要服务器端配置 listener.wss.external.cacertfile.


EMQ MQTT SSL 证书配置

生成 ca 证书:

cd /etc/letsencrypt/archive/mus.0.sw.iirii.com/
cat /etc/ssl/certs/DST_Root_CA_X3.pem chain.pem > ca.pem

编辑配置 etc/emq.confmqtt 相应的域名证书:

listener.ssl.external = 8883
listener.ssl.external.acceptors = 16
listener.ssl.external.max_clients = 1024
listener.ssl.external.access.1 = allow all
listener.ssl.external.handshake_timeout = 15s

listener.ssl.external.keyfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/privkey.pem
listener.ssl.external.certfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/cert.pem
listener.ssl.external.cacertfile = /etc/letsencrypt/archive/mus.0.sw.iirii.com/ca.pem

重启访问测试:

tcp://103.37.147.250:1883
ssl://mus.0.sw.iirii.com:8883

注意: Android 配置连接方式 ssl 需要服务器端配置 listener.ssl.external.cacertfile.


Comments

  • Allennex says: 2020-04-09 09:51:47

    Hello everyone! Seek out a demo of the game called X-Hex<a href=http://darude.site>.</a> The idea of the game is this<a href=http://darude.website>.</a> Field lozenge<a href=http://brodis.website>.</a> On the fields put labels<a href=http://brodis.site>.</a> Because of these points the field grows and becomes bigger<a href=http://brodis.online>.</a> At the moment when it begins to touch the opponent’s field<a href=http://gl-grand.website>.</a> Dots begin move now to the enemy, then back. The winner is the one who fills the entire field. There bonuses, a call to an aircraft that randomly bombes the enemy’s fields and can hurt yours. Very interesting toy. P<a href=http://adibodobe.site>.</a>S<a href=http://darude.online>.</a> Thanks anyway You can reply to the mail<a href=http://adibodobe.online>:</a> judbayneoranderson@gmail<a href=http://adibodobe.website>.</a>com

Cor-Ethan, the beverage → www.iirii.com