RobotStudio event

RobotWebServices subscriptions

Options
Maxim Riabichev
edited March 2021 in Developer Tools
Hello everyone,

In this post, I'd like to share some information regarding which approach one should take when working with subscriptions to resources made available via RobotWebServices.

Let's assume a scenario in which you are interested in receiving RMQ messages sent by a robot, so you're looking for a way to get access to this data via the DIPC queue resource "/rw/dipc{queue-name}".

You set up a subscription to this resource, but then you find out that the response you get omits some data which would otherwise be available via a GET request.

What gives?

The subscription mechanism on the resource "/rw/dipc{queue-name}" is provided by RWS to get an event when there is a message in that queue. The subscription event is not meant to fetch all information. To get all information, the user has to make a GET request.

Subscriptions are only supposed to provide notification so that the user can perform GET operation only after that and not all the time. This will assure to avoid unnecessary traffic and load on the system.

All the available information for the resource "/rw/dipc{queue-name}" is intentionally not included in the subscription event because that will make overhead and traffic in the WebSocket connection.

For a better understanding of a similar use-case of subscription, one can take a look at "/rw/rapid/taskselection;taskpanelchange" subscription.

For this particular subscription, RWS does not provide any information except change-count in the event. After getting the event, the user is supposed to make a GET request for reading the entire information.

There are many examples like this. One more is subscription on "/rw/system/energy".


The recommendation is therefore to set up a subscription for the relevant resource, and then when triggered, perform a GET request to fetch all necessary information.


In case anyone ends up in this situation, I hope it is now more clear on how to proceed.


Thanks for your attention and good luck with your projects!

Maxim Riabichev
PC Software Support Engineer
Post edited by Maxim Riabichev on

Comments

  • philldm
    Options
    Is this true for all subscriptions, for example even a rapid PERS value, e.g.:

        PERS num nD_Status := 1;

    Subscribe to:

        /rw/rapid/symbol/data/RAPID/T_ROB1/DData/nD_Status;value

    ?

    For simple values, it would be a lot easier to get the value in the WebSocket message.
  • Hello,

    An easy way to verify this is to subscribe to a RAPID variable, and see the response. If the lvalue is omitted, then you have to perform a GET request.

    Maxim Riabichev
    PC Software Support Engineer
  • I'm trying to subscribe to /rw/motionsystem/mechunits/ROB_1/jointtarget to get up to date robot positions but received the message: "Invalid resource URI in Create Subscription request"

    I am able to get a one-time response using a GET command. I assume this means that jointtarget is not available as a subscription?