使用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

#*********************************************************************
# 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"
#*********************************************************************

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

F_angT

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值