使用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吧,里面可以解决很多问题

相关推荐
QQ129584550411 小时前
ThingsBoard - APP密码输入错误提示改成中文
java·物联网·iot
星空真迷人13 小时前
嵌入式 WiFi 加持 普通设备也能联网 “唠嗑”
arm开发·stm32·单片机·嵌入式硬件·物联网·iot
电子科技圈17 小时前
芯科科技出展CES 2026并展出如何加速互联智能的未来
科技·嵌入式硬件·mcu·物联网·iot
云雾J视界1 天前
AI+IoT双轮驱动:构建风电设备预测性维护数字孪生体的全栈技术实践
人工智能·物联网·ai·lstm·iot·scada·金风科技
星空真迷人3 天前
恶劣环境稳如钟?CAN 总线是 “工业神经”
stm32·嵌入式硬件·mcu·物联网·iot
xyh4ck3 天前
[CVE-2025-15356]Tenda AC20 缓冲区溢出
网络·智能路由器·iot
星空真迷人3 天前
低功耗赋能:智能设备为何持久 “存活”?
stm32·单片机·mcu·物联网·iot
wotaifuzao4 天前
SPI通信:从原理到工程实践
stm32·单片机·mcu·物联网·iot·spi
梦想画家5 天前
工业级方案:基于Flink+MQTT实现IOT数据实时可靠存储至S3
mqtt·flink·iot
TDengine (老段)6 天前
TDengine 生态系统连接指南
大数据·数据库·物联网·时序数据库·iot·tdengine·涛思数据