Search code examples
javascriptnode.jsiotnode-red

Make custom node-red TCP function


I'm working on a node-red v 0.10.40 and i'm trying to make a function which, whenever it receives a msg, opens a connection on a a remote host, sends the payload and then closes the connection. When i use the regular IO TCP node, it opens the connection right away and sits there, which is a behaviour i do not want.

I have tried to use some code i found on the internet but i need to require the 'net' module. I included it in the global context of settings.js on my hardware but i still can't use it. I get the following error message when i try to call new net.Socket() : "cannot read property 'socket' of undefined"

Please help, thank you


Solution

  • Turns out the "TCP Request" node is supposed to do this when you set a 0ms timeout. However it doesn't. Hopefully we fixed this with dave from the node-red slack team and it will be released soon. Cheers and thanks dave!