如何创建本地 MQTT broker

创建本地 broker

https://test.mosquitto.org/

托管一个公开可用的 Mosquitto MQTT server/broker

mqtt broker listen port

mosquitto --help
mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300)

mosquitto is an MQTT v3.1.1/v3.1 broker.

Usage: mosquitto [-c config_file] [-d] [-h] [-p port]

 -c : specify the broker config file.
 -d : put the broker into the background after starting.
 -h : display this help.
 -p : start the broker listening on the specified port.
      Not recommended in conjunction with the -c option.
 -v : verbose mode - enable all logging types. This overrides
      any logging options given in the config file.

See http://mosquitto.org/ for more information.

开源 mqtt project

paho: https://www.eclipse.org/paho/
https://www.eclipse.org/paho/downloads.php
https://www.eclipse.org/paho/clients/python/

mqtt client

使用MQTT.fx接入物联网平台

  • MQTT.fx 是一款基于 Eclipse Paho,使用 Java 语言编写的 MQTT 客户端工具,支持通过 Topic 订阅和发布消息。
    使用MQTT.fx接入物联网平台
    https://www.alibabacloud.com/help/zh/doc-detail/86706.htm
    http://mqttfx.jensd.de/index.php

Paho-MQTT C接入示例

https://www.alibabacloud.com/help/zh/doc-detail/146611.htm

mosquitto client

安装 mosquitto client
# 安装 mosquitto client
sudo snap install mosquitto          # version 1.6.9, or
sudo apt  install mosquitto-clients
订阅信息
# 订阅信息
mosquitto_sub -h test.mosquitto.org -t "#" -v

mosquitto 的用法

mosquitto — an MQTT broker
https://mosquitto.org/man/mosquitto-8.html

开启 mqtt broker
mali@ubuntu:~$ mosquitto -p 6000
1594970141: mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) starting
1594970141: Using default config.
1594970141: Opening ipv4 listen socket on port 6000.
1594970141: Opening ipv6 listen socket on port 6000.
1594970189: New connection from 127.0.0.1 on port 6000.
1594970189: New client connected from 127.0.0.1 as mosqsub|22878-ubuntu (c1, k60).
1594970321: New connection from 127.0.0.1 on port 6000.
1594970321: New client connected from 127.0.0.1 as mosqpub|22920-ubuntu (c1, k60).
1594970321: Client mosqpub|22920-ubuntu disconnected.
mali@ubuntu:~$ mosquitto_sub -p 6000 -t "#"
this is my first attempt
mali@ubuntu:~$ mosquitto_pub -p 6000 -t "topic/test" -m "this is my first attempt"

mqtt test

mqtt_tcp_demo

mosquitto 连接aliyun

 mosquitto_sub -h a1DXwtzsiP1.iot-as-mqtt.cn-shanghai.aliyuncs.com -p 1883 -u '1905141934&a1DXwtzsiP1' -P 2AA01043034E5D330FC0180FF0F795C8C3183836 -i 'F0FE6BAA8B46|securemode=3,signmethod=hmacsha1,timestamp=1592747707145|' -t "#"

mqtt_aliyun_packet

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值