Hi @marcus-j-davies
thanks a lot for the sample flow. I have made a small change, I added nodes to genrate sample data to be sent to port 6000 and 5000, here it is:
[
{
"id": "02c9110b356fb24d",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "7ccc8e36a3bed2a0",
"type": "tcp in",
"z": "02c9110b356fb24d",
"name": "",
"server": "server",
"host": "",
"port": "5000",
"datamode": "stream",
"datatype": "utf8",
"newline": "\\n",
"topic": "",
"trim": false,
"base64": false,
"tls": "",
"x": 220,
"y": 440,
"wires": [
[
"16d0daee5a5eada1",
"abb1a9f5fca611ca"
]
]
},
{
"id": "81c4cfed94a3860d",
"type": "status",
"z": "02c9110b356fb24d",
"name": "get session for 6000",
"scope": [
"302fde5716edc7fa"
],
"x": 250,
"y": 155,
"wires": [
[
"36ca293c537788f9"
]
]
},
{
"id": "eb79e8684bc8a543",
"type": "change",
"z": "02c9110b356fb24d",
"name": "",
"rules": [
{
"t": "set",
"p": "C6000",
"pt": "flow",
"to": "status._session",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 150,
"wires": [
[]
]
},
{
"id": "302fde5716edc7fa",
"type": "tcp in",
"z": "02c9110b356fb24d",
"name": "",
"server": "server",
"host": "",
"port": "6000",
"datamode": "stream",
"datatype": "utf8",
"newline": "\\n",
"topic": "",
"trim": false,
"base64": false,
"tls": "",
"x": 220,
"y": 495,
"wires": [
[
"71bc710d74c4620b",
"407c540ca47bd0a8"
]
]
},
{
"id": "3b1ef32aac335848",
"type": "status",
"z": "02c9110b356fb24d",
"name": "get session for 5000",
"scope": [
"7ccc8e36a3bed2a0"
],
"x": 250,
"y": 110,
"wires": [
[
"54f99caffd8c7350"
]
]
},
{
"id": "319e5fb8d64d648d",
"type": "change",
"z": "02c9110b356fb24d",
"name": "",
"rules": [
{
"t": "set",
"p": "C5000",
"pt": "flow",
"to": "status._session",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 70,
"wires": [
[]
]
},
{
"id": "241abfd517f6e0e5",
"type": "tcp out",
"z": "02c9110b356fb24d",
"name": "",
"host": "",
"port": "",
"beserver": "reply",
"base64": false,
"end": false,
"tls": "",
"x": 865,
"y": 445,
"wires": []
},
{
"id": "ba656090023f1cef",
"type": "tcp out",
"z": "02c9110b356fb24d",
"name": "",
"host": "",
"port": "",
"beserver": "reply",
"base64": false,
"end": false,
"tls": "",
"x": 865,
"y": 505,
"wires": []
},
{
"id": "54f99caffd8c7350",
"type": "switch",
"z": "02c9110b356fb24d",
"name": "",
"property": "status.event",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "connect",
"vt": "str"
},
{
"t": "eq",
"v": "disconnect",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 450,
"y": 110,
"wires": [
[
"319e5fb8d64d648d"
],
[
"94d5ed987e3cd803"
]
]
},
{
"id": "94d5ed987e3cd803",
"type": "change",
"z": "02c9110b356fb24d",
"name": "",
"rules": [
{
"t": "delete",
"p": "C5000",
"pt": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 710,
"y": 110,
"wires": [
[]
]
},
{
"id": "36ca293c537788f9",
"type": "switch",
"z": "02c9110b356fb24d",
"name": "",
"property": "status.event",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "connect",
"vt": "str"
},
{
"t": "eq",
"v": "disconnect",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 450,
"y": 155,
"wires": [
[
"eb79e8684bc8a543"
],
[
"3bbd0fcc32e64e0d"
]
]
},
{
"id": "3bbd0fcc32e64e0d",
"type": "change",
"z": "02c9110b356fb24d",
"name": "",
"rules": [
{
"t": "delete",
"p": "C6000",
"pt": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 710,
"y": 185,
"wires": [
[]
]
},
{
"id": "16d0daee5a5eada1",
"type": "function",
"z": "02c9110b356fb24d",
"name": "Set Target",
"func": "const Target = flow.get(\"C5000\")\n\nif(Target){\n msg._session = flow.get(\"C5000\")\n return msg\n}\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 385,
"y": 440,
"wires": [
[
"241abfd517f6e0e5"
]
]
},
{
"id": "71bc710d74c4620b",
"type": "function",
"z": "02c9110b356fb24d",
"name": "Set Target",
"func": "const Target = flow.get(\"C6000\")\n\nif(Target){\n msg._session = flow.get(\"C6000\")\n return msg\n}\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 390,
"y": 495,
"wires": [
[
"ba656090023f1cef"
]
]
},
{
"id": "725c01aca20b4828",
"type": "debug",
"z": "02c9110b356fb24d",
"name": "debug 3",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 660,
"wires": []
},
{
"id": "4de9831d6d7b4578",
"type": "inject",
"z": "02c9110b356fb24d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 275,
"y": 745,
"wires": [
[
"574ef95a779aeb6b"
]
]
},
{
"id": "7737678484ea5f04",
"type": "tcp in",
"z": "02c9110b356fb24d",
"d": true,
"name": "",
"server": "client",
"host": "127.0.0.1",
"port": "6000",
"datamode": "stream",
"datatype": "buffer",
"newline": "",
"topic": "",
"trim": false,
"base64": false,
"tls": "",
"x": 285,
"y": 660,
"wires": [
[
"725c01aca20b4828"
]
]
},
{
"id": "574ef95a779aeb6b",
"type": "tcp request",
"z": "02c9110b356fb24d",
"d": true,
"name": "",
"server": "127.0.0.1",
"port": "5000",
"out": "sit",
"ret": "buffer",
"splitc": " ",
"newline": "",
"trim": false,
"tls": "",
"x": 640,
"y": 740,
"wires": [
[]
]
},
{
"id": "407c540ca47bd0a8",
"type": "debug",
"z": "02c9110b356fb24d",
"name": "TCP 6000 prijem",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 425,
"y": 545,
"wires": []
},
{
"id": "abb1a9f5fca611ca",
"type": "debug",
"z": "02c9110b356fb24d",
"name": "TCP 5000 prijem",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 410,
"y": 380,
"wires": []
},
{
"id": "f50df83545e79565",
"type": "inject",
"z": "02c9110b356fb24d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 490,
"y": 320,
"wires": [
[
"4d27d1893da65991"
]
]
},
{
"id": "4d27d1893da65991",
"type": "function",
"z": "02c9110b356fb24d",
"name": "Sample data for port 5000",
"func": "const Target = flow.get(\"C5000\")\n\nif (Target) {\n msg._session = flow.get(\"C5000\")\n \n}\nlet x = Math.floor((Math.random() * 200000) + 10000);\nmsg.payload = \"Port 5000: \" + x + \"\\r\\n\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 720,
"y": 320,
"wires": [
[
"241abfd517f6e0e5"
]
]
},
{
"id": "26b8a07258857617",
"type": "inject",
"z": "02c9110b356fb24d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 650,
"y": 580,
"wires": [
[
"4ebbfb334546900f"
]
]
},
{
"id": "4ebbfb334546900f",
"type": "function",
"z": "02c9110b356fb24d",
"name": "Sample data for port 6000",
"func": "const Target = flow.get(\"C6000\")\n\nif (Target) {\n msg._session = flow.get(\"C6000\")\n \n}\nlet x = Math.floor((Math.random() * 200000) + 10000);\nmsg.payload = \"Port 6000: \" + x + \"\\r\\n\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 880,
"y": 580,
"wires": [
[
"ba656090023f1cef"
]
]
}
]
There are only some problems, i have
- The flow works only with one connected client to port 5000 and one to port 6000. So if two clients connect to port 5000, only one recieves the data... This is a problem, but lets say not so big now.
2.Bigger problem is, than when Clients conect to port 5000 and then port 6000, the data is sent OK to both of them. But when one clients disconnects, than all data are sent to the second client. I was testing it using Hercules utilitz and you can see, that I have closed connestion 5000 on the left side of windows and then on the right side also data desired to port 5000 come to port 6000.