簡體   English   中英

在 React-Native Expo 上接收 MQTT 消息

[英]Receive MQTT messages on React-Native Expo

我嘗試了以下庫:

react-native-native-mqtt
react-native-mqtt
react_native_mqtt
sp-react-native-mqtt

他們中的大多數給了我同樣的錯誤:

null is not an object (evaluating 'Mqtt.createClient')
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:293:29 in invoke
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:154:27 in invoke
- node_modules/regenerator-runtime/runtime.js:189:16 in PromiseImpl$argument_0
- node_modules/react-native/node_modules/promise/setimmediate/core.js:45:6 in tryCallTwo
- node_modules/react-native/node_modules/promise/setimmediate/core.js:200:22 in doResolve
- node_modules/react-native/node_modules/promise/setimmediate/core.js:66:11 in Promise
- node_modules/regenerator-runtime/runtime.js:188:15 in callInvokeWithMethodAndArg
- node_modules/regenerator-runtime/runtime.js:211:38 in enqueue
- node_modules/regenerator-runtime/runtime.js:238:8 in exports.async
.... its pretty long and probably says nothing of value.

那些沒有給我這個錯誤的; 給了我關於 sockets 和緩沖區的錯誤,幾乎就像它試圖在 web sockets 上運行它一樣。

我在這里做錯了什么?

甚至可以在 android react-native 上獲取 MQTT 消息嗎?

Expo 是問題所在嗎?

我有同樣的問題。 一個 expo 項目和害怕從 Expo 彈出。

我的實際解決方案從這里開始!

經過大量研究,我找到了這個模塊。 Eclipse JS 的 Paho MQTT 客戶端

npm i paho-mqtt

Expo 零食舉例:

https://snack.expo.dev/@rizwanamjad/mqtt

https://snack.expo.dev/@eseg/mqtt

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM