How can i subscribe to topics using websockets?

How can i subscribe to topics using websockets?

I am able to setup the connection but dont know how to subscribe to the topic. Please help

Hi @codecracker2020, welcome to the forum. I think your question is missing a key bit of information - what are you connecting to exactly?

When you say 'subscribe to topics', I'm guessing you mean you are connecting to an MQTT broker over websockets?

If that is the case, what nodes are you using to do that - the MQTT nodes or the WebSocket nodes?

Thanks for the prompt response.. I am trying to establish a websocket connection with below url:
https://domainname:5051/my-service/websocket

After establishing websocket connection, i need to subscribe and start hearing to responses based on below topics. The number below indicate machine number.

/topic/units/112/activityrecords
/topic/units/255/activityrecords
/topic/units/811/activityrecords
/topic/units/758/activityrecords

Hi @codecracker2020

but again you have not said if you mean with MQTT or not. Nor have you said what nodes you are using.

I am using Websocket In and Websocket Out nodes. not MQTT.. I am using wss protocol.

The websocket protocol has no concept of topics or subscriptions... so you will need to use some application-level protocol over the connection. This is why I thought you were referring to MQTT.

1 Like

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