[英]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 零食举例:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.