TCP Request Node "Stop" after "Never - Keep Connection Open"?

Is there a way to "Stop" the TCP Request Node, whenever it is set to "Never - Keep Connection Open"?

I am currently going in and out TCP services across my network and every time I switch to a new device, the TCP Request Node keeps the previous one open, and adds the new connection in with the previous one and it is just hard to parse/differentiate between them, and prevents other devices from accessing the device.

... Now, I don't consider the statement above a bug... that is actually a cool feature that I/anyone can benefit from!!!....

But realy wished there was a way to "stop", and "start" a process programmatically whenever a new "HOST"/"PORT" is assigned for this node!

Thank you!

And while I am at it: Because of TCP bufferig my JSON string gets broken apart and in different payload therefore I am using the "JOIN" node.... I was wondering if this was the proper use for it... i have a "\n" separating the each payload but did not see a way to use it a deterministic way to identify between packages.

[{"id":"9eb5d09b.682c6","type":"tcp request","z":"7eeb7a14.fb2f14","server":"","port":"","out":"sit","splitc":" ","name":"","x":610,"y":240,"wires":[["4ad6112c.4fc52"]]},{"id":"750b3d2b.36c414","type":"ui_dropdown","z":"7eeb7a14.fb2f14","name":"DEVICE","label":"","tooltip":"","place":"Select option","group":"c367dbd3.d43168","order":1,"width":"4","height":"1","passthru":true,"options":[{"label":"","value":"dsa6tf6b","type":"str"},{"label":"","value":"d2pk5zuh","type":"str"}],"payload":"","topic":"","x":220,"y":180,"wires":[["2c77f590.6663fa"]]},{"id":"2c77f590.6663fa","type":"function","z":"7eeb7a14.fb2f14","name":"","func":"msg.port = 666;\nmsg.host = \"device-\" + msg.payload + \".local\";\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":180,"wires":[["9eb5d09b.682c6"]]},{"id":"2be194e6.0f004c","type":"inject","z":"7eeb7a14.fb2f14","name":"","topic":"","payload":"A","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"1","x":230,"y":220,"wires":[["2c77f590.6663fa"]]},{"id":"f4faa7e6.e48fe8","type":"inject","z":"7eeb7a14.fb2f14","name":"","topic":"","payload":"B","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":260,"wires":[["2c77f590.6663fa"]]},{"id":"4ad6112c.4fc52","type":"function","z":"7eeb7a14.fb2f14","name":"ascii -> string","func":"switch(msg.topic) {\n    \n  case '?':\n    break;\n\n  default:\n    msg.payload = msg.payload.toString('utf8');\n}\n\nreturn msg","outputs":1,"noerr":0,"x":780,"y":240,"wires":[["606f5a70.b77d04"]]},{"id":"12b2915a.2a3e8f","type":"inject","z":"7eeb7a14.fb2f14","name":"","topic":"","payload":"CLEAR?","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":300,"wires":[["30b6c65.315223a"]]},{"id":"606f5a70.b77d04","type":"join","z":"7eeb7a14.fb2f14","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":".1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":810,"y":280,"wires":[["517e0047.f6663"]]},{"id":"517e0047.f6663","type":"json","z":"7eeb7a14.fb2f14","name":"","property":"payload","action":"","pretty":false,"x":810,"y":320,"wires":[["48986cda.d6f444"]]},{"id":"30b6c65.315223a","type":"function","z":"7eeb7a14.fb2f14","name":"","func":"msg.port = 0; // ???\nmsg.host = \"\"; // ???\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":300,"wires":[["9eb5d09b.682c6"]]},{"id":"48986cda.d6f444","type":"debug","z":"7eeb7a14.fb2f14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":320,"wires":[]},{"id":"c367dbd3.d43168","type":"ui_group","z":"","name":"CONTROL","tab":"f09801a6.d260a","order":1,"disp":false,"width":"24","collapse":false},{"id":"f09801a6.d260a","type":"ui_tab","z":"","name":"TCP_TEST","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

Other flows I have come across pass a known "bad" port number and force a close on the TCP request node. Not really good programming practice, but it does appear to work. Like you, I would prefer an orderly way to connect in the chosen mode and to do a clean disconnect as well.

Hello!

Thank you for the response, I really did not considered that approach! .... I will give it a shot and hope it does work the way as "intended"!

EZ

wondering if sending a negative port number would accomplish the same thing. that also avoids affecting some other port that might be running, if one chooses unwisely.