首页 > 其他分享 >mosquitto

mosquitto

时间:2024-06-23 19:31:53浏览次数:3  
标签:false log admin 用户 mosquitto example

mosquitto.conf

mosquitto.conf是mosquitto的配置文件,

# Config file for mosquitto

# =================================================================
# General configuration
# =================================================================

per_listener_settings false
allow_zero_length_clientid false
check_retain_source false
max_inflight_messages 20
max_keepalive 60
persistent_client_expiration 1w
retain_available true
sys_interval 3600
listener 1883 0.0.0.0
# bind_address 127.0.0.1

# =================================================================
# Persistence
# =================================================================

persistence false

# =================================================================
# Security
# =================================================================

allow_anonymous false
password_file /etc/mosquitto/pwfile.example
acl_file /etc/mosquitto/aclfile.example

# =================================================================
# Debug configuration
# =================================================================

# log_dest file /var/log/mosquitto.log
# log_dest none
# log_type error
# log_type warning
# log_type notice
# log_type information
# connection_messages true
# log_timestamp true
# log_timestamp_format %Y-%m-%dT%H:%M:%S
# max_keepalive 5
# sys_interval 10

pwfile.example

设置用户名和密码,若客户端登录时,提供的用户名和密码不匹配,将无法连接mosquitto broker。

安装mosquitto时,附带安装了mosquitto_passwd,用户创建用户的可执行文件。

创建两个用户,分别是:admin和mosquitto

创建第一个用户admin:sudo mosquitto_passwd -c /etc/mosquitto/pwfile.example admin

创建第二个用户mosquitto:sudo mosquitto_passwd /etc/mosquitto/pwfile.example mosquitto
(注意:创建第二个用户时,不需要参数-c。若添加了参数-c,那么第一个用户会被第二个用户覆盖)

aclfile.example

可以限制指定用户对主题的发布或订阅权限。

例如:用户admin可以对 device/1001 发布,对 room/# 订阅。用户mosquitto可以对 # 发布和订阅。

user admin
topic write device/1001
topic read room/#
user mosquitto
topic readwrite #

标签:false,log,admin,用户,mosquitto,example
From: https://www.cnblogs.com/caojun97/p/18218513

相关文章

  • Network loop(managed by libmosquitto)
    mosquitto_loop_forever()&mosquitto_loop()mosquitto_loop_forever()是一个阻塞调用,适用于你只想在回调中处理传入消息的情况。换句话说,调用这个函数,该函数内部调用了一个while(1)循环和mosquitto_loop(),接下来你什么也不能干。mosquitto_loop_start()&mosquitto_loop_sto......
  • centos7 mosquitto (MQTT)安装/配置/自启动
    **************************************************************windows:>>一、安装及配置mosquitto1.下载并安装mosquitto(官网下载地址https://mosquitto.org/download/)>安装完成后进入安装目录1).编辑mosquitto.conf文件.注意系统防火墙得允许tcp1883端口#设......
  • Linux 安装Mosquitto服务
     1.安装依赖yuminstallgcc-c++cmakeopenssl-devellibuuid-develc-ares-develuuid-devellibwebsockets-devel.x86_64libwebsockets.x86_64-y2.下载mosquitto官网:https://mosquitto.org/cd/homewget--no-check-certificatehttps://mosquitto.org/files/source......
  • 阿里云ubuntu 部署mosquitto服务器
    阿里云ubuntu部署mosquitto服务器安装mosquittosudoaptinstallmosquitto添加用户名密码touch/etc/mosquitto/pwdfilesudochmod0700/etc/mosquitto/pwdfilesudochownmosquitto/etc/mosquitto/pwdfilemosquitto_passwd-b/etc/mosquitto/pwdfileusernamepass......
  • Windows10上安装Mosquitto的步骤(win10、win11 安装mqtt)
    目录· 前言· 1.下载安装· 2.设置Broker的IP和Port· 3.设置账户和密码· 4.重启服务mosquittobroker· 5.如何让Windows服务开机自启前言mosquitto是一款开源免费的软件,官网链接。它是一些可执行文件的集合,通过这些可执行文件,它提供broker,publish,subscribe功能......
  • docker部署开源MQTT平台mosquitto
    一、安装docker在开始之前,确保你的系统上已经安装了Docker。Docker提供了一个开放的平台,可以在容器中打包、分发和运行应用程序。你可以从Docker官方网站下载和安装适合你操作系统的Docker版本。二、拉取MosquittoDocker镜像这里我们以阿里云的Ubuntu系统为例。想要在docker中部......
  • mosquitto(MQTT)服务器搭建和基本使用
    一、安装搭建一个mqtt服务器,这里我们采用mosquitto1、下载地址:https://mosquitto.org/download/ 2、选择windows:https://mosquitto.org/files/binary/win64/mosquitto-2.0.18-install-windows-x64.exe 3、右键安装即可默认的安装路径在这里:C:\ProgramFiles\mosquitto......
  • 深入了解Mosquitto:MQTT消息的用法和介绍
    MQTT(MessageQueuingTelemetryTransport)是一种轻量级的消息传输协议,在物联网领域得到广泛应用。Mosquitto是一个流行的MQTT消息代理实现,它允许设备和应用之间进行高效的消息通信。本文将介绍Mosquitto的基本用法和特点,并提供代码演示。什么是Mosquitto?Mosquitto是一个开源的MQTT......
  • Mosquitto使用介绍:轻松构建MQTT通信
    在物联网(IoT)领域,实现设备之间的高效通信是至关重要的。MQTT(MessageQueuingTelemetryTransport)是一种轻量级的消息传输协议,适用于各种物联网应用。而Mosquitto作为MQTT协议的代表,为开发者提供了便捷的通信方式。本文将介绍如何使用Mosquitto构建MQTT通信,实现设备间的数据传输和交......
  • mosquitto遇到严重错误时会退出循环
    while(run){ do{ rc=mosquitto_loop(mosq,timeout,max_packets); }while(run&&rc==MOSQ_ERR_SUCCESS); /*Quitafterfatalerrors.*/ switch(rc){ caseMOSQ_ERR_NOMEM: caseMOSQ_ERR_PROTOCOL: caseMOSQ_ERR_INVAL: caseMOSQ_ERR_NOT_FO......