Dynamic IP address in node TCP in & out?

Hello,

I have a request regarding TCP in and TCP out nodes. They work perfectly.
However I would like to be able to pass the TCP address dynamically.
That is, I would like to fill in the destination IP address from the dashboard and then push it into a global context variable. This would then be reused by the TCP in/out node.
Do you think this is possible?

II am actually reviving this topic that was exposed in 2018.
There is indeed a way to create an environment variable or to use the Linux SED command to modify the flows.json but indeed it is more or less dynamic.
Thanks for your advice

Edit: I just found out that the UDP node can have the dynamic address and port via msg.ip and msg.port.
So maybe I'll go that way although the connection is not assured as it can be via TCP.

I tested this morning with UDP. So it works. For the UPD in node I have well the 2 messages msg.ip and msg.port that are displayed.
But I don't know how to pass these values to the UDP out node. It refuses my values passed via change nodes

UDP in --> OK
image

Change node to define a flow variables
image

Change node to define both msg.ip and msg.port
image

It works if i statically define the destination and port number

but it didn't works if i try to push the msg.ip and msg.port that came from change node node with the node UDP out cleared

What am I doing wrong ? :thinking:

I think it is possible.

I am not doing what you are doing (or want to do) but something similar.

What I have/do:
I have ONE machine that polls and gets my public IP address.
If it changes, I am told.
I press a button on the dashboard and the new IP address is sent to all my machines.
Some of the other machines have routines that also ping the public IP address.
So they would suddenly not be able to PING the public IP.
I'll cop that they stop for a while. (Outside the scope here)
The public IP is updated on receipt of the new message (IP) and then start pinging the new public IP address.

Do you think that is along the track you want/need?

thanks for the answer.
I'm just trying to fill in once from the dashboard the IP that my rs232--wifi gateway got via dhcp.
Then I do not intervene any more.
My software is installed at several people and therefore the IP configuration of the gateway is inevitably different. the user just needs to define it once and that's it

Well, you should be able to parse the RS-232 message and set the IP address automatically.

yes the info I get via UDP in but I can't find the right syntax to send to the UDP out node as I show on the debug.
Do you see a big mistake in my change node?

Sorry, I haven't actually loaded the flow.

I just saw the topic, had a quick read and replied.

Looking at the "It works if I statically define the destination" part I can't see what the real message looks like from the RS-232 port.

Oh!

Why do you have 2 change nodes after the inject node?

Shouldn't one be in the connection between where the RS-232 message is received and the next node?

Could you cut down the flow to the RS-232 in node to the node that sets the IP?
(and an example of what the message received looks like)

Can you show us what is coming out of the debug you have disabled ?

you mean this one?

This is just in anticipation of being able to use the dashboard to store the variables later. It's just for the demo. In the end there will be only one IP address field. Only 1 node change left

Sorry I don't understand the question. I'm not an English speaker and the translator doesn't help me on this one

image

Can you make a small flow that receives the RS-232 message and displays it.

Then we (as I'm sure @dceejay will try also) can may better see what is going on.

Your last reply.

The first picture is/shows the message being sent INTO the ask RS232 gateway node.
Why are you sending an IP address into that node?

That node (Ask RS232 gateway) is a request you send to..... what?

The second picture: udp node.
That seems (to me) to be what you just injected above.

I think there is more things happening here than are shown.
Ok, privacy...... Not helping.

But putting that aside, I am missing something.

You have a WiFi uplink (access to the internet) and that is connected via a serial port.
In the old days the smarter modems had things like AT commands to control them.

Normally serial ports don't allow complex messages like internet routers.
So sending a command to get/request the uplink IP would be a command.

I'll stop here.

My simple test seems to work... how exactly do you have the udp node(s) configured ?

[{"id":"0cb2cab620e5133f","type":"inject","z":"9a66423268ae47c4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":195,"y":195,"wires":[["4e7da2a4f4f61a62"]]},{"id":"4e7da2a4f4f61a62","type":"change","z":"9a66423268ae47c4","name":"","rules":[{"t":"set","p":"ip","pt":"flow","to":"192.168.1.218","tot":"str"},{"t":"set","p":"port","pt":"flow","to":"9999","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":385,"y":195,"wires":[["3544ad02120edec7"]]},{"id":"3544ad02120edec7","type":"change","z":"9a66423268ae47c4","name":"","rules":[{"t":"set","p":"ip","pt":"msg","to":"ip","tot":"flow"},{"t":"set","p":"port","pt":"msg","to":"port","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":595,"y":195,"wires":[["0d11396c7fd5478b","fc5a2156ebc99c67"]]},{"id":"0d11396c7fd5478b","type":"debug","z":"9a66423268ae47c4","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":195,"wires":[]},{"id":"fc5a2156ebc99c67","type":"udp out","z":"9a66423268ae47c4","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":805,"y":240,"wires":[]},{"id":"9beb1b234433e43e","type":"udp in","z":"9a66423268ae47c4","name":"","iface":"","port":"9999","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":240,"y":360,"wires":[["0ad4f9ebf4d57a39"]]},{"id":"0ad4f9ebf4d57a39","type":"debug","z":"9a66423268ae47c4","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":525,"y":360,"wires":[]}]

@Trying_to_learn Thank you so much for trying to help me, I really appreciate it

I had forgotten to place the change node before calling the UDP out node :upside_down_face:. It's better this way, I don't get any error messages. But ....

If I fill in the UDP out node with the IP and the port I get the data from my inverter without any problem !

Here is the configuration of the node when it works:

image

if I remove the port number from the node, it doesn't work. It's like it doesn't receive msg.port ?!

on the other hand, if I delete the IP address and leave the port number, it works as expected.

There must be something so obvious that I don't see it. Some days are like that.

The gateway i'm using is this one Elfin ew10a
image

The But is a bit confusing.

That normally means the next bit goes against what was just said.
But then you go on and say:

So that is good - yes?

I am not sure why you are putting the 192.168.1.114 in the address field.
I thought you said the IP address was dynamic.

Oh, the translation problems make it not always clear.
What I meant by dynamically setting the IP address is the possibility to pass it to TCP out/in nodes with a msg.payload and not to enter it once and for all in the statytic configuration of the node in question.

With the UDP out node I've seen that it's possible to pass the IP port values via msg.port and msg.ip.
These are filled in once and for all at the start of my flows by the user via the dashboard. The gateway having obtained its IP address via DHCP, this one is obviously different for each one. Hence the need to fill it in at least once.

Now with the UDP out node, I found my solution. I can pass the IP address to the node via a global variable that was previously filled in from the user.
I hope I have been clearer and that the translator doesn't play tricks on me

In my tests with UDP out, I manage to use the msg.ip, but not the msg.port. But fortunately the port is fixed, so it works like that for me.

Ok, good to hear you got it working.

Also good to hear you got it all working automatically too.

1 Like

dynamic port works for me...

image

[{"id":"2c40f9172a1d19b7","type":"udp out","z":"3b9a9d02857dd4a7","name":"","addr":"","iface":"","port":"","ipv":"udp4","outport":"","base64":false,"multicast":"false","x":680,"y":1080,"wires":[]},{"id":"2e938d0a578b2881","type":"udp in","z":"3b9a9d02857dd4a7","name":"2001","iface":"","port":"2001","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":630,"y":960,"wires":[["b54bf3cf43d58410"]]},{"id":"b54bf3cf43d58410","type":"debug","z":"3b9a9d02857dd4a7","name":"debug 30","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":780,"y":960,"wires":[]},{"id":"7f63bedbd47a7d14","type":"udp in","z":"3b9a9d02857dd4a7","name":"2002","iface":"","port":"2002","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":630,"y":1020,"wires":[["5186b80b1336d33c"]]},{"id":"5186b80b1336d33c","type":"debug","z":"3b9a9d02857dd4a7","name":"debug 31","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":780,"y":1020,"wires":[]},{"id":"f11d075eabbbc488","type":"inject","z":"3b9a9d02857dd4a7","name":"127.0.0.1:2001","props":[{"p":"payload"},{"p":"ip","v":"127.0.0.1","vt":"str"},{"p":"port","v":"2001","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":480,"y":1060,"wires":[["2c40f9172a1d19b7"]]},{"id":"e85512d2892ad1c5","type":"inject","z":"3b9a9d02857dd4a7","name":"127.0.0.1:2002","props":[{"p":"payload"},{"p":"ip","v":"127.0.0.1","vt":"str"},{"p":"port","v":"2002","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":480,"y":1100,"wires":[["2c40f9172a1d19b7"]]}]

Stephen,
you are totally right, it works also for the port number.
I'm not sure what I did wrong last time, but this is ok now.
Thanks for testing and correcting my false statement. I appreciate it.

image
image

1 Like

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