"UDP in" setting port dynamically

Online help says:
image

However, the node does not consider a msg.port variable (unlike "UDP out").

Is there any workaround for that(?)

msg.ip and msg.port are output variables, from the UDP in node. You can not set port and ip dynamically with them

for me it seems as if they are variables for the "udp out".
I would like to use them for the "udp in" as also mentioned in the online help but this unfortunately doesn't work :frowning:

I cannot see that mentioned in the online help. It says:
" It also provides msg.ip and msg.port set to the ip address and port from which the message was received."
Which means that the node outputs those values. Not that you can pass them in to the node.

yes, you are right.
Now I also see that this is the meaning of this sentence :frowning:

It is really a pity that "udp out" supports this flexible handling and "udp in" not...

Why do you want to set it dynamically? for end user configuration? other reason?

Would an env variable for the port number suffice?

You can use ${ENV_VAR} in place of a port number if you wish.

https://nodered.org/docs/user-guide/environment-variables

I have to connect to a unit which can work with different port-numbers so I want to configure the port-number in the dashboard.
Can I also use flow or global variables in place of a port number within the "udp" node (?)

No. Your only options are

  • static fixed number
  • Environment variable (changes only take affect after node-red startup)
  • Request to the author to add functionality
  • fork the node and add the capability yourself
1 Like

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