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

相关推荐
K成长日志2 天前
BLE链路层--比特流处理
网络·物联网·网络协议·蓝牙·iot·ble·无线
Devlab3 天前
LVGL设计大师——网页版anyui来了!!
嵌入式硬件·物联网·低代码·ui·iot
TDengine (老段)6 天前
TDengine taosX 与 Explorer — 数据集成与可视化管理
大数据·数据库·物联网·时序数据库·iot·tdengine·涛思数据
电子科技圈6 天前
芯科科技推出其功耗最低的低功耗蓝牙SoC产品BG2B, 能效、安全性及集成度领先
嵌入式硬件·mcu·物联网·网络安全·智能家居·iot·交通物流
TDengine (老段)6 天前
TDengine taosAdapter — 多协议网关详解
大数据·数据库·物联网·时序数据库·iot·tdengine·涛思数据
星空真迷人7 天前
嵌入式鸿蒙并非精简版,核心究竟是什么?
stm32·单片机·嵌入式硬件·物联网·华为·harmonyos·iot
光源【时光寸寸又逢君】10 天前
第三方平台预览我方级联监控点串流问题排查
c++·iot
慧都小妮子10 天前
ThingsBoard PE 智慧灌溉:实现精准灌溉与水资源优化利用
物联网·mqtt·智慧农业·iot·规则引擎·thingsboard·精准灌溉
mengpp_12345612 天前
泵站自动化控制系统:数据安全管控,筑牢水务运行防护墙
物联网·自动化·iot
时光の尘15 天前
【凌鸥LKS32】基础篇(二)·Timer定时器实现LED闪烁
单片机·mcu·物联网·iot·timer·lks07