搜索插件、代码仓与 APP 分类

插件详情v10.14.0

mqtt_client

一个基于服务器和浏览器的 Dart MQTT 客户端,支持普通、安全套接字和 WebSocket。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
12.5万
喜欢数
551
Pub 分数
160

安装插件

flutter pub add mqtt_client

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

mqtt_client 包是 Dart 编写的 MQTT 客户端实现,可实现设备与服务器之间的实时通信。它支持标准、安全(TLS)和 WebSocket 连接,适用于服务器端和基于浏览器的应用程序。该包专为跨平台使用而设计,在 Android、iOS、Web、macOS、Windows 和 Linux 上均可无缝运行。非常适合物联网项目,能够实现轻量级、发布-订阅式消息传递,具有低延迟和高效率的特点。

适合场景

  • 物联网设备通信
  • 实时数据流
  • 远程传感器监控
  • 智能家居自动化
  • 实时仪表板更新
  • 云到设备的消息传递

主要特点

  • 支持通过 TCP、TLS 和 WebSockets 的 MQTT
  • 跨平台兼容性
  • 轻便高效
  • 强大的连接处理
  • 发布/订阅消息模型
  • 自动重连

适合对象

  • 物联网开发者
  • 实时应用构建工具
  • 需要发布/订阅的后端服务
  • 基于网络的仪表板
  • 需要实时更新的移动应用

使用建议

  • 需要正确的代理设置
  • 可能需要额外配置才能建立安全连接
  • 在未调优的情况下,不适合高频、低延迟场景
  • 依赖外部 MQTT 代理的可用性

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

mqtt_client

Build Status FOSSA Status

A server and browser based MQTT client for Dart.

The client is an MQTT v3(3.1 and 3.1.1) implementation(an equivalent MQTT v5 client can be found here) supporting subscription/publishing at all QOS levels, keep alive and synchronous connection. The client is designed to take as much MQTT protocol work off the user as possible, connection protocol is handled automatically as are the message exchanges needed to support the different QOS levels and the keep alive mechanism. This allows the user to concentrate on publishing/subscribing and not the details of MQTT itself.

Examples of usage can be found in the examples directory. An example is also provided showing how to use the client to connect to the mqtt-bridge of Google's IoT-Core suite. This demonstrates how to use secure connections and switch MQTT protocols. The test directory also contains standalone runnable scripts demonstrating subscription, publishing and topic filtering.

The server client supports both normal and secure TCP connections and secure(wss) and non-secure(ws) websocket connections. The browser client supports only secure(wss) and non-secure(ws) websocket connections.

The client has been used successfully with the MQTT brokers from several of the major cloud providers IOT/MQTT platforms, including :-

  • Google IOT Core
  • Amazon AWS
  • Microsoft Azure
  • IBM

It has also been used with a range of both publicly available brokers such as Mosquitto and proprietary ones. An example using the adafruit MQTT broker for flutter can be found here.

The code is originally a port from the C# nMQTT client library to Dart.

Please read the changelog for details related to specific versions.

Installation

If you are using the client in a flutter environment on Android or iOS devices then the following device permission settings are necessary.

iOS

Add the following keys to your Info.plist file, located in ios/Runner/Info.plist:

<key>NSLocalNetworkUsageDescription</key>
<string>Looking for local tcp Bonjour service</string>
<key>NSBonjourServices</key>
<array>
  <string>mqtt.tcp</string>
</array>
Android

Add the following Android permissions to the AndroidManifest.xml file, located in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

License

FOSSA Status

所属分类

依赖

依赖清单 7 项

源码仓库

使用此插件的项目

所在榜单