MQTT简介

在这里插入图片描述
https://mqtt.org/

mqtt协议说明

MQTT Version 5.0
https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html
broker的实现有很多,参考:
https://mqtt.org/software/
流行broker实力对比
https://wivwiv.com/post/best-mqtt-broker/

流行的有:

  • Mosquitto,C实现,单机、带客户端
    Mosquitto is an open source implementation of a server for version 5.0, 3.1.1, and 3.1 of the MQTT protocol. It also includes a C and C++ client library, and the mosquitto_pub and mosquitto_sub utilities for publishing and subscribing.
    在这里插入图片描述

  • EMQX,erlang实现,可扩展、分布式
    EMQX broker is a fully open source, highly scalable, highly available distributed
    MQTT messaging broker for IoT, M2M and Mobile applications that can handle tens of millions of concurrent clients.

  • Moquette,java实现,可在工程里嵌入(式)
    Moquette aims to be a MQTT compliant broker. The broker supports QoS 0, QoS 1 and QoS 2.
    Its designed to be evented, uses Netty for the protocol encoding and decoding part.

Mosquitto

eclipse对mqtt broker的官方实现,An open source MQTT broker
https://mosquitto.org/

  • The server listens on the following ports:

1883 : MQTT, unencrypted, unauthenticated
1884 : MQTT, unencrypted, authenticated
8883 : MQTT, encrypted, unauthenticated
8884 : MQTT, encrypted, client certificate required
8885 : MQTT, encrypted, authenticated
8886 : MQTT, encrypted, unauthenticated
8887 : MQTT, encrypted, server certificate deliberately expired
8080 : MQTT over WebSockets, unencrypted, unauthenticated
8081 : MQTT over WebSockets, encrypted, unauthenticated
8090 : MQTT over WebSockets, unencrypted, authenticated
8091 : MQTT over WebSockets, encrypted, authenticated

cedalo 官方管理后台
用于物联网和流处理的实时消息代理和电子表格
https://cedalo.com/

EMQX

mqtt协议的第三方实现,有开源版和企业版,使用广泛
https://www.emqx.com/en/try?product=broker
https://github.com/emqx
有k8s的empx-operator的实现
开源版区别查看:企业版与开源版区别

快速上手

on Mac

# 安装mosquitto
brew install mosquitto
# 启动
brew services start mosquitto
# 测试
#订阅消息
mosquitto_sub -t 'test/topic' -v
#发消息
mosquitto_pub -t 'test/topic' -m 'hello world'

在这里插入图片描述

EMQX

  • EMQX Docker 镜像安装
docker run -d --name emqx -p 1883:1883 -p 8081:8081 -p 8083:8083 -p 8883:8883 -p 8084:8084 -p 18083:18083 emqx/emqx

控制台:http://localhost:18083/#/,默认账密admin/public

  • 使用端口:
    8883端口(ssl),最大连接数10万
    1883端口(tcp):最大连接数100万

    在这里插入图片描述

  • 测试

#订阅消息
mosquitto_sub -p 1883 -t 'test/topic' -v
#发消息
mosquitto_pub -p 1883 -t 'test/topic' -m 'hello world'

在这里插入图片描述

参考:
MQTT数据结构说明:http://www.steves-internet-guide.com/mqtt-protocol-messages-overview/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值