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/