shehankonecranes / sp-react-native-mqtt

MQTT Client native module for react-native
68 stars 55 forks source link

null is not an object (evaluating 'Mqtt.createClient') #13

Open wiserdivisor opened 3 years ago

wiserdivisor commented 3 years ago

I'm running the example that's given in the Readme in my App.js file. I'm using react-native with expo for android development.

Error :

null is not an object (evaluating 'Mqtt.createClient')
- node_modules/sp-react-native-mqtt/index.js:66:16 in module.exports.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
- node_modules/sp-react-native-mqtt/index.js:66:16 in module.exports.createClient
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:15561:31 in commitHookEffectListMount
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:15618:35 in commitPassiveHookEffects
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:265:4 in invokeGuardedCallbackImpl
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:476:2 in invokeGuardedCallback
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18795:29 in flushPassiveEffectsImpl
- node_modules/scheduler/cjs/scheduler.development.js:653:23 in unstable_runWithPriority
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:6153:23 in scheduleRefresh
- node_modules/react-refresh/cjs/react-refresh-runtime.development.js:218:8 in mountedRoots.forEach$argument_0
* [native code]:null in forEach
- node_modules/react-refresh/cjs/react-refresh-runtime.development.js:210:4 in performReactRefresh
- node_modules/react-native/Libraries/Core/setUpReactRefresh.js:43:6 in Refresh.performReactRefresh
- node_modules/metro/src/lib/polyfills/require.js:627:10 in setTimeout$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:383:16 in callTimers
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:416:4 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:109:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue

What am I doing wrong here?

Tonisg91 commented 2 years ago

I'm running the example that's given in the Readme in my App.js file. I'm using react-native with expo for android development.

Error :

null is not an object (evaluating 'Mqtt.createClient')
- node_modules/sp-react-native-mqtt/index.js:66:16 in module.exports.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
- node_modules/sp-react-native-mqtt/index.js:66:16 in module.exports.createClient
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:15561:31 in commitHookEffectListMount
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:15618:35 in commitPassiveHookEffects
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:265:4 in invokeGuardedCallbackImpl
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:476:2 in invokeGuardedCallback
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18795:29 in flushPassiveEffectsImpl
- node_modules/scheduler/cjs/scheduler.development.js:653:23 in unstable_runWithPriority
- node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:6153:23 in scheduleRefresh
- node_modules/react-refresh/cjs/react-refresh-runtime.development.js:218:8 in mountedRoots.forEach$argument_0
* [native code]:null in forEach
- node_modules/react-refresh/cjs/react-refresh-runtime.development.js:210:4 in performReactRefresh
- node_modules/react-native/Libraries/Core/setUpReactRefresh.js:43:6 in Refresh.performReactRefresh
- node_modules/metro/src/lib/polyfills/require.js:627:10 in setTimeout$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:383:16 in callTimers
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:416:4 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:109:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue

What am I doing wrong here?

Hello. Have you been able to solve the problem? I have just the same error. My app starts from expo but with a bare-workflow template

wiserdivisor commented 2 years ago

@Tonisg91 Hello Toni, I did not in fact solve it. I was actually trying to get alerts from an IoT to RN App by MQTT so I just implemented push notifs in my API to get the job done. If you're looking at something similar then visit Pushy.com for an easy-to-use and free push notif service. ... EDIT :: Just another tip. Don't use expo, its very limiting in terms of what other libraries you can and cannot use. Just eject from expo or make a barebones react native app (best).