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

相关推荐
电子科技圈13 小时前
芯科科技助力涂鸦智能推出免编码AIoT平台创新智能照明开发
科技·嵌入式硬件·mcu·物联网·智能家居·智能硬件·iot
电子科技圈3 天前
芯科科技持续推动智能网联及边缘AI加速发展
人工智能·科技·嵌入式硬件·mcu·物联网·智能硬件·iot
帅次3 天前
系统分析师-嵌入式系统分析与设计
嵌入式硬件·mcu·物联网·proteus·iot·嵌入式实时数据库·rtdbs
peixiuhui9 天前
EdgeGateway 快速开始手册-表达式 Modbus 报文格式
人工智能·mqtt·边缘计算·iot·modbus tcp·iotgateway·modbus rtu
peixiuhui10 天前
EdgeGateway 快速开始手册-WEB登录
人工智能·mqtt·边缘计算·iot·modbus·iotgateway·开源网关
peixiuhui13 天前
突破边界!RK3576边缘计算网关:为工业智能注入“芯”动力
人工智能·物联网·边缘计算·rk3588·iot·rk3568·rk3576
QQ129584550413 天前
ThingsBoard - APP首页修改为手工选择组织
前端·javascript·物联网·iot
xu_wenming13 天前
物联网Wi-Fi 6(802.11ax)和 Wi-Fi 5(802.11ac)的差异
嵌入式硬件·mcu·物联网·iot
peixiuhui13 天前
Iotgateway技术手册-6. 数据流程
网关·iot·iotgateway·开源网关·采集软件·开源mqtt·开源modbus
peixiuhui13 天前
Iotgateway技术手册-1. 项目概述
linux·网关·iot·modbus·数据采集网关·iotgateway·采集软件