使用moquette mqtt发布wss服务

文章目录

概要

moquette是一款不错的开源mqtt中间件,github地址:https://github.com/moquette-io/moquette。我们在发布mqtt服务的同时,是可以提供websocket服务器的,有些场景下需要用到,比如使用JS进行数据访问的。本文描述了如何进行wss的配置,即带ssl的安全连接。

一、制作的ssl证书

制作证书的方法有很多,我们这边使用腾讯云的免费证书进行制作,有效期是1年(以前阿里的也是1年,现在是3个月了,吃相难看啊)。制作完成后,下载JKS格式的证书

二、配置wss

提示:这里我并没有找到官方的配置文档,哪位同学有的话,也可以评论区留言下

我们找到了其中一个commit中提到的配置方法:Introduced WSS to fix issue #8

bash 复制代码
#*********************************************************************
# Secure Websocket port (wss)
# decommend this to enable wss
#*********************************************************************
# secure_websocket_port 8883

#*********************************************************************
# SSL tcp part
#  jks_path: define the file that contains the Java Key Store,
#            relative to the current broker home
#
#  key_store_password: is the password used to open the keystore
#
#  key_manager_password: is the password used to manage the alias in the
#            keystore
#*********************************************************************
# ssl_port 8883
#jks_path serverkeystore.jks
#key_store_password passw0rdsrv
#key_manager_password passw0rdsrv

#*********************************************************************
# The interface to bind the server
#  0.0.0.0 means "any"
#*********************************************************************

参考上面的配置,我们修改配置文件如下:

bash 复制代码
port 1883

websocket_port 50002
secure_websocket_port 50003
ssl_port 8883
jks_path /iot/config/www.xxxx.com.jks
key_store_password xxxxxx
key_manager_password xxxxxx

小结

moquette还是不错的,就是文档相对少了点,多学会看github的issue吧,里面可以解决很多问题

相关推荐
光源【时光寸寸又逢君】2 天前
第三方平台预览我方级联监控点串流问题排查
c++·iot
慧都小妮子2 天前
ThingsBoard PE 智慧灌溉:实现精准灌溉与水资源优化利用
物联网·mqtt·智慧农业·iot·规则引擎·thingsboard·精准灌溉
mengpp_1234564 天前
泵站自动化控制系统:数据安全管控,筑牢水务运行防护墙
物联网·自动化·iot
时光の尘7 天前
【凌鸥LKS32】基础篇(二)·Timer定时器实现LED闪烁
单片机·mcu·物联网·iot·timer·lks07
K成长日志9 天前
BLE链路层空口包--数据物理信道PDU
网络·物联网·网络协议·嵌入式·蓝牙·iot·ble
技术硬汉9 天前
4G/5G蜂窝天线增益越大越好吗?怎么选适合自己的天线
物联网·5g·信息与通信·iot
mengpp_1234569 天前
城市排水泵站物联网监控系统:智能值守,革新市政运维模式
物联网·智慧城市·iot
gcygeeker9 天前
Home Assistant 读取 ESXi温度
esxi·iot·hass·homeassistant
CC1802539448611 天前
AIoT智能传感器—让万物“感知与思考”推荐适用模组ESP32-C6系列
iot
电子科技圈14 天前
第二代无线平台历久弥新,赋能物联网创新迭代
人工智能·嵌入式硬件·mcu·物联网·设计模式·硬件架构·iot