Home Community Blog Buy Now
Blog

Misty Community Forum

How to unregister all events?

If I do not unregister an event subscription before closing a WebSocket from offboard (to /pubsub), is there some way to unregister it later?

In general, can I perform a bulk unregister of events? (E.g., get a list of all subscriptions created from past WebSocket connections that were not unregistered, and then unregister each.)

My motivating use-case is that in practice I might drop a WebSocket connection before being able to send a 'Operation': 'subscribe', 'Type': 'SkillData', ... message. Then, after trying to reconnect with the same EventName, the response is

{"eventName":"SkillData","message":"Registration Status: Cannot register an event with same name (SkillData) as a previously registered event."}

Thus far, I have only had success by changing the EventName or rebooting the robot. I am OK to simply generate a new name, but I am concerned that there is some memory leak onboard.

Hi Scott, you can unregister for all events by using the Command Center Unregister option in Advanced Options and not entering in an event name.

Where is the “Unregister” option? I located an “Unsubscribe” button and tried it without entering an event name, but the error remains.

Besides using the Command Center as you describe, I found the actual API command used by tracing the Command Center: for the Unsubscribe action without event name, it sends

{"$id":"1","Operation":"unsubscribe","Message":""}

over the WebSocket connection. Therefore, I also tried to send this from my own code, but the error remains.

Can you reproduce the error that I described? Alternatively, can someone confirm that there are no bad side effects of randomly generating a different EventName to avoid the error?

@slivingston, I’ve been able to reproduce this using Simple WebSocket Client - Chrome Web Store. Steps:

  1. Open a WebSocket connection
  2. Send a message to subscribe to an event with event name myEvent
  3. Close the WebSocket connection without unsubscribing from myEvent
  4. Open another WebSocket connection
  5. Send an unsubscribe message without specifying an event (in theory this would end all subscriptions)
  6. Send a message to subscribe to an event with event name myEvent. Attempt fails with message "Registration Status: Cannot register an event with same name (myEvent) as a previously registered event."

This may be a bug, or perhaps there’s some undocumented behavior that we need to provide information about.

Per your question:

If there are side effects, I do not believe they’re severe… I believe this is actually how the Misty Robotics Skill Runner web page streams SkillData messages (by prepending the event name with a random sequence of numbers at subscribe time). I’ll see if someone with more knowledge can share it here.

1 Like

As far as I am concerned, this is a sufficient solution. We can mark this as resolved.