Is there a way to set connections as properties on subflows

Hi, I was hoping to create a subflow which could read data from a websocket and send an acknowledgement message back before outputting to the main flow. This appears to be possible but, the whole reason I'd like to put this into a subflow is so that I could create multiple instances of this subflow each connecting to a different websocket. Unfortunately, it appears that the websocket node has to be directly aware of the connection rather than being able to do any form of lookup.

Is there a way around this limitation or am I stuck copying and pasting any logic that is tied directly to the processing of a websocket connection? Would it be possible to extend NodeRed to enable said capabilities? And if so, where should I turn my attention next if I was to contribute them to the project?


Hi @cwalter5

You should be able to use Subflow Properties to do this.

  1. In the Websocket node inside the subflow, set the URL to connect to as ${WebSocket_URL}
  2. In the Subflow properties dialog, add a new Environment Variable, call it WebSocket_URL.

You should then find each instance of the subflow has a WebSocket_URL as a field you can config in its edit dialog.

All being well, that will let you customise the WebSocket endpoint for each subflow instance.

Thanks for the quick response. I'll get back to you once I get a chance to test it out.

I got it working .Thank you for your help.

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