Notification API 2.0 share one WebSocket connection for multiple device subscriptions


I wanted to implement a microservice that listens to all operations for all devices in a specific tenant.
I am aware of that one WS connection could be shared when the device are using the same subscription name.

So I tried to implement that but I’m currently confused and stuck by the concepts the SDK is offering me.
Here are my concrete questions:

  1. I can create one subscription of type “mo” with a filter “operation”. This subscription is always bound to a source / single device, so there is no option to add multiple sources / devices per subscription, correct? How can I use the same subscription name for multiple devices? Just creating n-requests for each device and the same subscription name? Or should I retrieve the subscription with the same name and just change the source? How can I identify the n subscription if they all share the same name e.g. if I want to unsubscribe?

  2. The token that I need is bound to a subscriber ID and a subscription. Is my assumption correct that I just need one token after I created n subscriptions with the same name?

If my assumptions are wrong. How do I re-use the same WS connection for multiple devices? Are there any examples?

Answering my own question:

To 1: You have to create multiple subscriptions with the same subscription name. The source can be either a device or a device group. Retrieving the subscription is not necessary. You can only identify by retrieving them and filter on sources. Device Groups might not work with operations as there is no type “operationsWithChildren”.

To 2: For each connection you need one token. So you just connect once with the subscription name you share across all devices / device groups.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.