mosquitto 配置以及使用说明

mosquitto是一个支持Linux以及Windows平台的mqtt服务器。在项目中用于实现对单台或多台仪器的远程控制,下面记录使用过程中的几个要点

  • 只能本机客户端访问,无法远程访问
    解决方法:需要手动配置一下监听端口,然后启动的时候指定配置文件。

  • 常用配置

  1. 默认的配置文件为安装目录下的:mosquitto.conf
  2. 打开配置文件,设置监听端口号2005,默认为1883
# listener port-number [ip address/host name/unix socket path]
listener 2005
  1. 配置访问的用户名密码,关闭匿名访问
# Defaults to false, unless there are no listeners defined in the configuration
# file, in which case it is set to true, but connections are only allowed from
# the local machine.
allow_anonymous false
  1. 设置用户名密码存储的文件,这里采用默认的文件pwfile.example
# See the TLS client require_certificate and use_identity_as_username options
# for alternative authentication options. If an auth_plugin is used as well as
# password_file, the auth_plugin check will be made first.
password_file pwfile.example
  1. 设置用户名密码,打开Windows超级终端power shell,进入到安装目录。通过mosquitto_passwd.exe来配置用户名密码,分别指定存储文件以及用户名,回车以后设置两次密码。打开安装目录下的pwfile.example可以看到刚才添加的用户名
.\mosquitto_passwd.exe -c .\pwfile.example croxs
  1. 启动服务器,进入到安装目录 -v可以将日志显示到命令框
.\mosquitto.exe -c .\mosquitto.conf -v
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值