How to unsubscribe OPC UA nodes?

In the following flow,
I can subscribe OPC UA nodes without problem.
But I don't know how to unsubscribe them.
I have tried several methods, but anyone doesn't work.

Anyone can help out? Thank you very much.

[
    {
        "id": "062a6f6d48c1614e",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c46e9b8a7b164c0b",
        "type": "junction",
        "z": "062a6f6d48c1614e",
        "x": 600,
        "y": 320,
        "wires": [
            [
                "a0926ffa3d78a02c"
            ]
        ]
    },
    {
        "id": "5e08746194dfda16",
        "type": "debug",
        "z": "062a6f6d48c1614e",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 140,
        "wires": []
    },
    {
        "id": "a0926ffa3d78a02c",
        "type": "OpcUa-Client",
        "z": "062a6f6d48c1614e",
        "endpoint": "b19f60f1f161efad",
        "action": "subscribe",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": "2",
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "folderName4PKI": "",
        "name": "OPC UA Client",
        "x": 760,
        "y": 140,
        "wires": [
            [
                "5e08746194dfda16"
            ]
        ]
    },
    {
        "id": "09cfc0df8496658c",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "Sub",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 140,
        "wires": [
            [
                "107dc37d2856d23a"
            ]
        ]
    },
    {
        "id": "107dc37d2856d23a",
        "type": "function",
        "z": "062a6f6d48c1614e",
        "name": "sub multi nodes",
        "func": "msg.topic = \"multiple\";\nmsg.action = \"subscribe\";\nmsg.interval = 2000;\nmsg.payload = [];\nmsg.payload.push({ nodeId:\"ns=1;i=1447\",browseName:\"TankLevel\"});\nmsg.payload.push({ nodeId: \"ns=1;i=1431\", browseName: \"Pressure\"});\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 140,
        "wires": [
            [
                "a0926ffa3d78a02c"
            ]
        ]
    },
    {
        "id": "7af68e9315de13e5",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "Unsub",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 240,
        "wires": [
            [
                "edc77c3f7fb9f7f0"
            ]
        ]
    },
    {
        "id": "edc77c3f7fb9f7f0",
        "type": "function",
        "z": "062a6f6d48c1614e",
        "name": "unsub multi nodes",
        "func": "msg.topic = \"multiple\";\nmsg.action = \"unsubscribe\";\nmsg.interval = 2000;\nmsg.payload = [];\nmsg.payload.push({ nodeId: \"ns=1;i=1447\", browseName: \"TankLevel\" });\nmsg.payload.push({ nodeId: \"ns=1;i=1431\", browseName: \"Pressure\" });\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 240,
        "wires": [
            [
                "c46e9b8a7b164c0b"
            ]
        ]
    },
    {
        "id": "3a61646a2570b95e",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "unsub ns=1;i=1447",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "action",
                "v": "unsubscribe",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "ns=1;i=1447",
        "x": 430,
        "y": 360,
        "wires": [
            [
                "c46e9b8a7b164c0b"
            ]
        ]
    },
    {
        "id": "c578c12cc933218d",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "unsub ns=1;i=1431",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            },
            {
                "p": "action",
                "v": "unsubscribe",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "ns=1;i=1431",
        "x": 430,
        "y": 400,
        "wires": [
            [
                "c46e9b8a7b164c0b"
            ]
        ]
    },
    {
        "id": "10e404d02eca90f8",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "Delete Subscrition",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "currentSession",
        "payload": "{\"action\": \"deletesubscription\"}",
        "payloadType": "json",
        "x": 450,
        "y": 60,
        "wires": [
            [
                "a0926ffa3d78a02c"
            ]
        ]
    },
    {
        "id": "b3d65d8a2834f321",
        "type": "function",
        "z": "062a6f6d48c1614e",
        "name": "unsub multi nodes",
        "func": "msg.topic = [{ nodeId: \"ns=1;i=1447\", browseName: \"TankLevel\" },{ nodeId: \"ns=1;i=1456\", browseName: \"LevelLowLimit\" }];\nmsg.action = \"unsubscribe\";\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 300,
        "wires": [
            [
                "c46e9b8a7b164c0b"
            ]
        ]
    },
    {
        "id": "ada6619ff9503459",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "Unsub",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 300,
        "wires": [
            [
                "b3d65d8a2834f321"
            ]
        ]
    },
    {
        "id": "b19f60f1f161efad",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://opcuademo.sterfive.com:26543",
        "secpol": "None",
        "secmode": "None",
        "none": true,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    }
]

Look examples folder and OPCUA-TEST-NODES.json

On first tab left upper corner:
image

Thanks for your reply.

I had read the examples. In the example, unsubscribe for a node's subscription is shown.
Also, the delete of current subscription is given.

I tried to unsubscribe group of nodes and one node by each, but both don't work.

Finally, I find the opc ua client will return subscription id in the first message.
Now I try delete the subscription by the id and succeed as follows.

[
    {
        "id": "062a6f6d48c1614e",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b6114949e910441c",
        "type": "junction",
        "z": "062a6f6d48c1614e",
        "x": 1060,
        "y": 200,
        "wires": [
            [
                "109ed62325840ee9",
                "d66d159a3c6cbe88"
            ]
        ]
    },
    {
        "id": "5e08746194dfda16",
        "type": "debug",
        "z": "062a6f6d48c1614e",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1100,
        "y": 80,
        "wires": []
    },
    {
        "id": "a0926ffa3d78a02c",
        "type": "OpcUa-Client",
        "z": "062a6f6d48c1614e",
        "endpoint": "b19f60f1f161efad",
        "action": "subscribe",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": "2",
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "folderName4PKI": "",
        "name": "OPC UA Client",
        "x": 760,
        "y": 140,
        "wires": [
            [
                "d378781203ac90ed"
            ]
        ]
    },
    {
        "id": "09cfc0df8496658c",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "Sub",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 140,
        "wires": [
            [
                "107dc37d2856d23a"
            ]
        ]
    },
    {
        "id": "107dc37d2856d23a",
        "type": "function",
        "z": "062a6f6d48c1614e",
        "name": "sub multi nodes",
        "func": "msg.topic = \"multiple\";\nmsg.action = \"subscribe\";\nmsg.interval = 2000;\nmsg.payload = [];\nmsg.payload.push({ nodeId:\"ns=1;i=1447\",browseName:\"TankLevel\"});\nmsg.payload.push({ nodeId: \"ns=1;i=1431\", browseName: \"Pressure\"});\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 140,
        "wires": [
            [
                "a0926ffa3d78a02c"
            ]
        ]
    },
    {
        "id": "10e404d02eca90f8",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "Delete Subscrition",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "currentSession",
        "payload": "{\"action\": \"deletesubscription\"}",
        "payloadType": "json",
        "x": 450,
        "y": 60,
        "wires": [
            [
                "a0926ffa3d78a02c"
            ]
        ]
    },
    {
        "id": "d378781203ac90ed",
        "type": "switch",
        "z": "062a6f6d48c1614e",
        "name": "",
        "property": "topic",
        "propertyType": "msg",
        "rules": [
            {
                "t": "else"
            },
            {
                "t": "eq",
                "v": "subscriptionId",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 930,
        "y": 140,
        "wires": [
            [
                "5e08746194dfda16"
            ],
            [
                "b6114949e910441c"
            ]
        ]
    },
    {
        "id": "d66d159a3c6cbe88",
        "type": "debug",
        "z": "062a6f6d48c1614e",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1160,
        "y": 160,
        "wires": []
    },
    {
        "id": "b54199ded9253079",
        "type": "function",
        "z": "062a6f6d48c1614e",
        "name": "function 1",
        "func": "if (msg.topic == \"subscriptionId\"){\n    context.subscriptionId = msg.payload;\n    node.warn(\"subscriptionId stored:\" + context.subscriptionId);\n    return null;\n}\nmsg.topic = context.subscriptionId\nnode.warn(\"set topic:\" + context.subscriptionId);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 240,
        "wires": [
            [
                "0dad9e0ef1664f98",
                "2709a94eb36b124e"
            ]
        ]
    },
    {
        "id": "f82f29b10d35d2c8",
        "type": "inject",
        "z": "062a6f6d48c1614e",
        "name": "delete sub by subscriptionId",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"action\":\"deletesubscription\"}",
        "payloadType": "json",
        "x": 180,
        "y": 240,
        "wires": [
            [
                "b54199ded9253079"
            ]
        ]
    },
    {
        "id": "109ed62325840ee9",
        "type": "link out",
        "z": "062a6f6d48c1614e",
        "name": "subscriptionId",
        "mode": "link",
        "links": [
            "27984b12c9f05c9a"
        ],
        "x": 1125,
        "y": 220,
        "wires": []
    },
    {
        "id": "27984b12c9f05c9a",
        "type": "link in",
        "z": "062a6f6d48c1614e",
        "name": "subscriptionId",
        "links": [
            "109ed62325840ee9"
        ],
        "x": 275,
        "y": 300,
        "wires": [
            [
                "b54199ded9253079"
            ]
        ]
    },
    {
        "id": "2709a94eb36b124e",
        "type": "debug",
        "z": "062a6f6d48c1614e",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 340,
        "wires": []
    },
    {
        "id": "0dad9e0ef1664f98",
        "type": "switch",
        "z": "062a6f6d48c1614e",
        "name": "",
        "property": "payload.action",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "deletesubscription",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 610,
        "y": 240,
        "wires": [
            [
                "a0926ffa3d78a02c",
                "90debfdc965c9a40"
            ]
        ]
    },
    {
        "id": "90debfdc965c9a40",
        "type": "debug",
        "z": "062a6f6d48c1614e",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 860,
        "y": 260,
        "wires": []
    },
    {
        "id": "b19f60f1f161efad",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://opcuademo.sterfive.com:26543",
        "secpol": "None",
        "secmode": "None",
        "none": true,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    }
]

Thank you for your answer.

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