Updating node when backend gets updated

I am trying to build a MQTT pub/sub node, which gets the mqtt broker and topic information from the backend after user authentication and inputs. Problem is, user can update the mqtt broker information in the backend, and the node deployed with older broker info needs to be updated manually. What options do i have to make such an update automatic? Is there a way to refresh a deployed node using a REST call or something similar to nudge it to ask for broker information again?

There is no real reason why you couldn't implement a REST API within your custom node. Node-RED already has 2 ExpressJS apps available to use, 1 for admin and one for user access. You would want to use the admin one here I would think. The code for uibuilder has a number of admin API's defined though none of them are for external access per-se. You would be responsible for retaining the settings across restarts of Node-RED however so you may need to write any changes to a file somewhere secure.

The other approach might be to turn things on their head. Make the broker available by name rather than IP address and then you don't need to worry about that part (maybe, depends on what you are doing). Make the backend publish a file containing the topic when it changes. Then your node could always pick up the latest from a known location. Not sure how you would trigger the lookup though - periodic check?

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