Reputation: 31
Is there any way to use TCP instead of websocket in react native paho mqtt?
Upvotes: 2
Views: 2270
Reputation: 2634
As @hardillb says, react-native-paho-mqtt
only supports WebSocket because React Native itself doesn't support raw TCP out of the box. That said if you could write a wrapper to wrap https://github.com/PeelTechnologies/react-native-tcp in an API that looks like a WebSocket, you could pass your wrapper to react-native-paho-mqtt
like this - theoretically that'd work, albeit a bit messily.
Upvotes: 2
Reputation: 59801
The Paho JavaScript client only supports MQTT over WebSockets because it is intended to be used in the browser.
You could look at the mqtt package (https://www.npmjs.com/package/mqtt) on npm which can be used natively or in the browser and is capable of both MQTT over Websockets and native MQTT, assuming the underlying JavaScript sandbox will allow full TCP sockets.
Upvotes: 1