搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

所在榜單