0

I am using Paho Mqtt JS (https://github.com/eclipse/paho.mqtt.javascript) on React Native via the bridge (https://github.com/Introvertuous/react_native_mqtt)

It works well on the old version of React Native

"react": "~15.4.0-rc.4",
"react-native": "0.40.0",
"react-native-elements": "^0.9.2",
"react-native-storage": "^0.1.4",
"react-native-vector-icons": "^4.0.0",
"react_native_mqtt": "^1.1.4"

But it doesn't work any more with new versions:

"react": "16.0.0-alpha.12",
"react-native": "0.46.4",
"react-native-elements": "^0.15.0",
"react-native-storage": "^0.2.2",
"react-native-vector-icons": "^4.2.0",
"react_native_mqtt": "^1.1.6"

I always get the error "Object {invocationContext: undefined, errorCode: 16, errorMessage: "AMQJS0016E Invalid MQTT message type 0."}"

I think there are changes in the new version of RN may break the mqtt feature (may be related to websocket ?)

I tried a lot of ways but can not find any clue to solve the issue. Please help me... any idea is welcomed...

NgocDB
  • 131
  • 5

1 Answers1

0

This is/was due to a React Native bug.

Binary WebSockets in react native on android were broken by commit 93a1d5 (which first landed in the 0.46 release) and later fixed by 7e29b1 (which will land in 0.48 but was also cherry-picked into 0.47 final).

So, you should find that updating React Native to 0.47.* fixes the issue for you. If you need to monkey-patch 0.46 instead, just apply the one-liner 7e29b1. HTH.

Rob Hogan
  • 2,442
  • 19
  • 23