0

What I am trying to do is publish a message from a device in one registry to a device in another registry.

What I found out is that you can only publish to topics in the registry your device is in and if you try to publish to a topic in another registry you get a EOFException and you get disconnected from the MQTT server.

The flow I was trying to go for is I have a registry of mobile devices (phones) that have their own topics to do things but they also need to communicate to a hub registry that communicates with IoT devices (gets/updates device information) which also have their own IoT registry

As I said I can publish messages to topics in my registry without error but as soon as I try to do it outside my registry I get an error.

Is there no way to have inter-registry communication?

What is a "standard" way to communicate between devices through different topics if you cant do cross registry?

tyczj
  • 71,600
  • 54
  • 194
  • 296

1 Answers1

1

You can achieve your goal using Cloud Functions that handle the data received thought Cloud IoT Core and PubSub in a registry A then sending this data as a configuration message do a device on the registry B.

The flow will be something like: Device 1 > MQTT Server Registry A > Pub/Sub Topic Registry A > Cloud Functions > HTTP Config message to > Registry B > MQTT Server Registry B > Devices 2

You can see in this tutorial that I wrote about Cloud IoT Core and I show how to send configuration messages to the devices. In your case, the only change that you need is that the config message will go to a device in a different registry.

Link to the tutorial: https://medium.com/google-cloud/gps-cellular-asset-tracking-using-google-cloud-iot-core-firestore-and-mongooseos-4dd74921f582

Code part that sends config messages, but in my code, the registry is a constant variable: https://github.com/alvarowolfx/asset-tracker-gcp-mongoose-os/blob/master/functions/index.js#L22

Hope that this can help you.

  • I came across your tutorial about a month ago but have yet to read it, I will make sure to do that. However what is the point of Registries if you cant communicate between them, it seems very limited and I cant see a scenario where you would want/need that – tyczj Mar 16 '18 at 00:14
  • But in any way, you cannot talk between devices using Cloud IoT Core. To send messages from one device to another you have to follow that same path that I said. The only way for the device to receive a message is thought config messages. If you try to publish a message on the other device topic directly, you will get a permission denied, only if you maintain the certificates to connect to both devices topics, but will not make much sense to do this. – Alvaro Viebrantz Mar 16 '18 at 16:41
  • Ah so can I not create my own "topics"? It seems I can only publish to `device/{deviceId}/events` and I can only subscribe to `/devices/{deviceId}/config` and I do see that in your example so are those the only 2 topics that you can sub/pub to? – tyczj Mar 16 '18 at 17:52
  • Yeah, you cannot create your own topic, but you can use "subfolders" after the events topic. You can only publish on your own device tree like you mentioned (`device/{deviceId}/events`) and also only subscribe to your own device config topic. https://cloud.google.com/iot/docs/how-tos/mqtt-bridge#publishing_telemetry_events Just for curiosity, AWS IoT Shadow also has this kind of restriction. – Alvaro Viebrantz Mar 16 '18 at 22:18