Multiple topics in web socket


I have about a hundred of GPS trackers. I would like to create a separate web socket topic for every single gps tracker, and then update web page (with latest lat/lon position) via web sockets in "near real live".

At the moment I know how to do that by hand - creating one or few web-sockets topics.
But I haven't find a way how to do that by script or dynamically? Is that possible.
For security reason I do not want to create a json with all trackers.

I will appreciate any help.

The core websocket nodes use a URL rather than a topic. You could include a topic in the payload and then move things around using a change node.

Alternatively, you could use uibuilder to build your web pages. It provides you with a websocket interface that looks exactly like the message passing you get in Node-RED so you can use whatever you like including msg.topic, msg.payload, etc.

The uibuilderfe library is the front-end library that you put into your web page and provides the communications magic.

yes, sorry I've asked about topics, but I mean url

So is it possible in Node-Red to create hundreds of web socket with specific url for (in my case) specific tracker without doing it one-by-one manually?


I believe that the websocket node will create the url when Node-RED starts (or the node is deployed) so it isn't dynamic.

The uibuilder websocket connection is much the same. It builds a connection for each instance of uibuilder that you deploy. However, as I say, uibuilder hides all of the implementation details from you and you can use the socket connection to pass messages just as they are in Node-RED itself.

So, in your case, you have incoming data from your GPS devices to Node-RED, presumably you use a flow to make the topic for the incoming data match the specific device. Using uibuilder, you can simply pass that msg to your front-end and process it there however you like.

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