部署MQTT云服务

Centos安装

  1. 配置emqx的源
curl -s https://assets.emqx.com/scripts/install-emqx-rpm.sh | sudo bash
  1. 安装emqx
sudo yum install emqx -y
  1. 启动emqx
sudo systemctl start emqx

如果要卸载

sudo yum remove emqx
  1. 后台配置

访问前,服务端的端口18083权限打开。

截屏2024-12-01 08.53.43\"\"

xxx.xxx.xxx:18083

默认登录账号:admin,public。首次登录会要求更新密码。

如果要支持tcp/ssl/ws/wss这几种监听,也需要把相应的端口打开以及服务器端口权限打开。

\"\"

测试访问

使用mosquitto测试

这里使用的是ubuntu系统上的mosquito_sub/pub工具测试。先安装工具:

sudo apt-get install mosquitto-clients

订阅

mosquitto_sub -h www.xxx.xxx -t \"test\" -v

发布

mosquitto_pub -h www.laumy.tech -t \"test\" -m \"hello world\"

使用MQTTX软件测试

下载地址:https://mqttx.app/zh/downloads

建立一个回话连接用于订阅消息
\"\"

接着对填写订阅主题

\"\"

再建立一个回话用于发布消息

\"\"

连接上后进行发布主题
\"\"

这样订阅的回话就收到订阅消息了

\"\"

开启SSL/TLS连接

参考:https://docs.emqx.com/zh/emqx/v5.8/network/overview.html

启动异常排查

查找emqx.log

cd /
find -name \"emqx.log*\"

参考:

  1. https://docs.emqx.com/zh/cloud/latest/connect_to_deployments/react_sdk.html

  2. https://docs.emqx.com/zh/emqx/v5.8/connect-emqx/developer-guide.html