Changing Host IP address modbusTcp

Hello,

I have implemented a Modbus TCP Master application using Node-Red. I am able to establish the read properly if I go to the flow settings and enter the Host IP address to the Server settings page. However now I want to have the user enter the Host IP address using a text box. I am referring to these links:


and I am able to get the IP address from the text box and send it to the modbustcp node. However every time the node tries to reconnect it keeps using the IP address that has been set in the flow settings of the node. Now there are two possibilities that could be messing up what I am doing -

  1. The variable that I am passing to the modbustcp node is incorrect
  2. Whenever the node - modbustcp tries to reconnect it keeps using the default values, so maybe I have to restart it by letting it know that it has to use the values received.

As far as Point 1 goes I have tried : node.host = in msb.payload OR msg - Both do not seem to work or rather it could be point 2 now.
2. Maybe I will have to restart the node programmatically for it to establish a socket on the new IP address.
I am trying it for one day and could not get to it. Tried looking for help online but I did not find anyone who ran into a similar issue.
Has anyone changed the IP address of the host programmatically while using the modbustcp node.
In fact I tried changing the poll rate dynamically but that also did not work. Not sure what is going on.
Any help will be appreciated.
Thanks
AJ

1 Like

I don't use the node, but if the API defined in the ReadMe doesn't include IP address, what makes you think you can do it?

In fact there is even an issue opened on the github page that you linked to that says that's it isn't possible today.

You could fork it, fix it & do a pull request?

The beauty of open source.

Even if the author doesn't accept your PR you can use your fork quite easily....
npm install mygithubname/node-red-contrib-modbustcp

Thanks @Steve-Mcl and @ukmoose

So the feature is not available. Thanks @ukmoose for pointing to the issue. Looks like I will have to fork it and fix it. Will give it a shot.

Thanks for your help

1 Like

@ajaymn,
Did you get to make it work? I am using another package (node-red-contrib-modbus), but if you got it working, I would gladly try it out as I'm facing the same issue.