Hi all,
I am new to this. So please forgive me if I ask a silly question.
I created a simple UDP ping-pong function:
1. Endpoint A (port 3000) sends a Ping to Endpoint B (port 3001)
2. Endpoint B (port 3001) replies a Pong to Endpoint A (port 3000)
[{"id":"725b7ffb.59aa","type":"inject","z":"e559e2e2.79d9a","name":"Send Ping","topic":"","payload":"Ping","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":1760,"wires":[["c9181d5.3ccece"]]},{"id":"6fe3ee5a.ffadf","type":"udp out","z":"e559e2e2.79d9a","name":"Send from port 3000","addr":"","iface":"","port":"","ipv":"udp4","outport":"3000","base64":false,"multicast":"false","x":920,"y":1700,"wires":[]},{"id":"71434c52.25bea4","type":"udp in","z":"e559e2e2.79d9a","name":"Listen on port 3000","iface":"","port":"3000","ipv":"udp4","multicast":"false","group":"","datatype":"utf8","x":110,"y":1600,"wires":[["8cdf279f.2a9148","ed3ba85b.cea8b8"]]},{"id":"8cdf279f.2a9148","type":"debug","z":"e559e2e2.79d9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":390,"y":1560,"wires":[]},{"id":"ed3ba85b.cea8b8","type":"delay","z":"e559e2e2.79d9a","name":"Delay 5s","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":1640,"wires":[["c9181d5.3ccece"]]},{"id":"ea6dce7b.5d07d","type":"inject","z":"e559e2e2.79d9a","name":"Send Pong","topic":"","payload":"Pong","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":2200,"wires":[["7ddf4466.e25d7c"]]},{"id":"93f14deb.fb968","type":"udp out","z":"e559e2e2.79d9a","name":"Send from port 3001","addr":"","iface":"","port":"","ipv":"udp4","outport":"3001","base64":false,"multicast":"false","x":840,"y":2140,"wires":[]},{"id":"f002937.fa9307","type":"udp in","z":"e559e2e2.79d9a","name":"Listen on port 3001","iface":"","port":"3001","ipv":"udp4","multicast":"false","group":"","datatype":"utf8","x":110,"y":2020,"wires":[["63d71c31.13bf34","ef120942.f7ef88"]]},{"id":"63d71c31.13bf34","type":"debug","z":"e559e2e2.79d9a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":390,"y":1960,"wires":[]},{"id":"ef120942.f7ef88","type":"delay","z":"e559e2e2.79d9a","name":"Delay 5s","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":2080,"wires":[["7ddf4466.e25d7c"]]},{"id":"c9181d5.3ccece","type":"function","z":"e559e2e2.79d9a","name":"To Endpoint B on port 3001","func":"msg.ip = \"localhost\";\nmsg.port = 3001;\nreturn msg;","outputs":1,"noerr":0,"x":640,"y":1700,"wires":[["6fe3ee5a.ffadf"]]},{"id":"7ddf4466.e25d7c","type":"function","z":"e559e2e2.79d9a","name":"Reply with Pong","func":"let message = {\"ip\":msg.ip, \"port\": msg.port, \"payload\": \"Pong\"}\nreturn message;","outputs":1,"noerr":0,"x":600,"y":2140,"wires":[["93f14deb.fb968"]]},{"id":"2c812ae9.c673d6","type":"comment","z":"e559e2e2.79d9a","name":"Endpoint A","info":"","x":80,"y":1560,"wires":[]},{"id":"a21bd587.ca1008","type":"comment","z":"e559e2e2.79d9a","name":"Endpoint B","info":"","x":80,"y":1980,"wires":[]}]
I expect Endpoint A receives a Pong from Endpoint B (port 3001) which is specified in Endpoint B's UDP Out. However, Endpoint A actually shows Pong is from port 3000 which is wrong. What did I do wrong?
Node Red: 0.18.7
Nodejs: 8.11.2
OS: Ubuntu 16.04
Thanks for help.
Cheers,
Paul