[MQTT] Device A publishes but Device B unable to receive updates

I created a React Native mobile Android app where I made use of Losant REST API. I was able to send data regular from mobile to Losant.

Since I was having difficulty integrating MQTT with a mobile Android app, I decided to use MQTT from within browser environment to subscribe to the channel. I used a Firefox browser connecting to wss://broker.losant.com:443. For this connection, I used the same device ID (XXX) and credentials from the mobile app. Firefox browser subscribed to channel losant/XXX/state, where XXX was the device ID. I used MQTT JS. No problem. It works.

Now, I created another device on Losant. I ran a parallel client on Edge browser, which now has its own device ID (YYY) and credentials. Edge browser connects. It is properly authenticated by Losant. It subscribes to losant/XXX/state but Edge browser is not getting the state updates. Firefox continues to receive the updates.

I don’t think it’s browser issue. Shouldn’t multiple subscribers get informed when subscribed to the same channel? The workflow is simple: just Device connected to Debug. Thanks.

It is possible to subscribe to other device’s state topics, however they must be using an access key/secret that allows access to both devices.

If you created specific access keys for each device, then one device will not be able to read the data from another.

Here are a couple of solutions:

  1. Give both devices the same tag and create an access key that provides access for devices with that tag. This access key/secret will then be shared by both devices.
  2. Use commands and a workflow to propagate device data in a more controlled way. Use a Device Trigger to run a workflow whenever state is pushed. You can then add a Device Command output to send this state to any devices that need it. This prevents directly subscribing to state topics and provides a more controllable and secure approach to routing data.

Thx. Will try it out.