Udp out node bind to local port

Hello everyone,

In the process of understanding how SRT protocol works, I would like to pass the SRT trought nodered which is a tool i really appreciate to troubleshoot.

So it seems simple but might not be so.

The idea is to listen on a UDP port, be able to extract part of the data and resend it to the end user. Problem is i didn't find a way to change the binding of the port dynamicaly for the user to be able to respond correctly. I'm basically looking for msg.localport property which doesn't exists.

So do you think it could be possible to use JS function directly and be able to change the local binding port for every message.
Thanks a lot for your help and the wunderful tool nodered is.

The UDP node does not say that you can send a message, so that means that you can't (assuming the docs are right). It probably binds to the port when node-red runs so it would require mods to the node to allow that.

You could use an environment variable which would mean you could set it externally, but it would require a node-red restart to use the changed env var.

Thanks Colin,

This is basically what I figured out. So i’ll Have to do it with js functions directly. Does anyone have an example on how to do it?

Thanks

If some wonders...
it wass as simple as this:

const dgram = global.get('dgram');

const server = dgram.createSocket('udp4');

server.bind(msg.out_port);

server.send(msg.payload,msg.port,msg.ip, ()=> {
  server.close();});

return msg;
1 Like

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