robhogan / react-native-paho-mqtt

react-native-paho-mqtt
91 stars 32 forks source link

Not working on Android #11

Closed prameetchakraborty closed 6 years ago

prameetchakraborty commented 6 years ago

The package doesn't seem to work on Android. It says onConnectionLost:Error: AMQJS0007E Socket error: Unknown socket error. (for the exact same parameters)

Works fine on iOS

11xdev commented 6 years ago

I've started to see this recently; I'm guessing it's a change in the way I'm using one of the APIs that's caused it to appear as I haven't updated RN for a while. I have a crash log from iOS through Bugsnag below.

RN 0.48.3


Error: AMQJS0007E Socket error: Unknown socket error.   
    at ClientImplementation._disconnected (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:119733:41) 
    at WebSocket.socket.onerror (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:119170:23)   
    at WebSocket.dispatchEvent (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:15516:35) 
    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:16273:16   
    at RCTDeviceEventEmitter.emit (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:6964:35)   
    at MessageQueue.__callFunction (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:5154:42)  
    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:4970:15    
    at MessageQueue.__guard (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:5125:9)  
    at MessageQueue.callFunctionReturnFlushedQueue (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:4969:13)  
    at http://localhost:8081/debuggerWorker.js:72:58

Possibly related or maybe another issue...

Seems to appear when the app comes out from the background only - I disconnect from MQTT when the app goes into the background and reconnect when it's active again.

Error · INVALID_STATE_ERR Raw node_modules/react-native/Libraries/WebSocket/WebSocket.js:163:6value node_modules/react-native-paho-mqtt/src/Pinger.js:31:24value node_modules/react-native-paho-mqtt/src/Pinger.js:41:19 node_modules/react-native/Libraries/Core/Timers/JSTimers.js:257:6 node_modules/react-native/Libraries/Core/Timers/JSTimers.js:149:24_callTimer node_modules/react-native/Libraries/Core/Timers/JSTimers.js:409:25callTimers node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:313:9value node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108:26 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:278:24value node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:107:17callFunctionReturnFlushedQueue

robhogan commented 6 years ago

Thanks for the report - there’s a chance this could be the keepalive timer kicking in while the socket isn’t ready, as reported in another issue. I won’t be able to have a look until next week unfortunately, but you could maybe try with the keepalive config set to 0?

11xdev commented 6 years ago

Thanks @rh389 ; that makes sense based on my recent changes. The app is more stateful and disconnects when it goes into the background, reconnects when it becomes active again. I've done some initial testing with keepAlive set to 0 and it hasn't crashed yet :).

@prameetchakraborty hopefully you can confirm the same!

prameetchakraborty commented 6 years ago

Well for me, the issue was resolved. The issue was the port I was using in my MQTT URL. There was an SSL issue in the backend. Now it's working.

theSupermacy commented 5 years ago

@11xdev When does the INVALID_STATE_ERR occurs? Can you give the steps to replicate it?