Write string value to OPC UA Server - contrib-opcua-server

Hello,

I'm trying to let a Client node write a value to a variable of the address space in my OPC UA server.

As long as the variable in the Server is specified as Integer, Double, etc. everything works fine. I can write and read the variable with a Client without any problems.

However, if I specify the variable as string, the following happens:

  1. Reading the initialized value - OK
  2. Writing new value - two messages from Client node:

"Counter: Second set value by Input b"

"Counter: Payload value, setting value to [{"_msgid":"1","payload":"2","topic":"3","datatype":"4","browseName":"5"},"385fde3613f0f306","b","ns=1;s=count","String","Counter"]"

with "b" from the first statement being the value I wanted to write

  1. Trying to read the value again - message from Client node

"Client node error on: error: [" error at active reading: serviceResult = BadInternalError (0x80020000)"]"

My flow:

[
    {
        "id": "056d99c0561209fd",
        "type": "OpcUa-Client",
        "z": "4571363c02da6541",
        "endpoint": "d6af2ba71bd244b8",
        "action": "read",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": "1",
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "folderName4PKI": "",
        "name": "",
        "x": 840,
        "y": 600,
        "wires": [
            [
                "e80207e73aea2dd9"
            ]
        ]
    },
    {
        "id": "e568aa60eb783cc1",
        "type": "OpcUa-Item",
        "z": "4571363c02da6541",
        "item": "ns=1;s=count",
        "datatype": "String",
        "value": "",
        "name": "Counter",
        "x": 620,
        "y": 600,
        "wires": [
            [
                "056d99c0561209fd"
            ]
        ],
        "icon": "node-red-contrib-opcua-server/icon.png"
    },
    {
        "id": "cdba768a51f2843e",
        "type": "inject",
        "z": "4571363c02da6541",
        "name": "Add item",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "x": 440,
        "y": 600,
        "wires": [
            [
                "e568aa60eb783cc1"
            ]
        ]
    },
    {
        "id": "e80207e73aea2dd9",
        "type": "debug",
        "z": "4571363c02da6541",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1050,
        "y": 600,
        "wires": []
    },
    {
        "id": "ca3305551b7a3a9b",
        "type": "OpcUa-Item",
        "z": "4571363c02da6541",
        "item": "ns=1;s=count",
        "datatype": "String",
        "value": "",
        "name": "Counter",
        "x": 640,
        "y": 500,
        "wires": [
            [
                "a85637302bde4a56"
            ]
        ],
        "icon": "node-red-contrib-opcua-server/icon.png"
    },
    {
        "id": "a85637302bde4a56",
        "type": "OpcUa-Client",
        "z": "4571363c02da6541",
        "endpoint": "d6af2ba71bd244b8",
        "action": "write",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "folderName4PKI": "",
        "name": "",
        "x": 860,
        "y": 500,
        "wires": [
            [
                "7bc9af43b5d78cc1"
            ]
        ]
    },
    {
        "id": "e4253eb280cffc69",
        "type": "inject",
        "z": "4571363c02da6541",
        "name": "Add item",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "b",
        "payloadType": "str",
        "x": 440,
        "y": 500,
        "wires": [
            [
                "ca3305551b7a3a9b"
            ]
        ]
    },
    {
        "id": "7bc9af43b5d78cc1",
        "type": "debug",
        "z": "4571363c02da6541",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1050,
        "y": 500,
        "wires": []
    },
    {
        "id": "7bcb25894b455949",
        "type": "opcua-compact-server",
        "z": "4571363c02da6541",
        "port": "4840",
        "endpoint": "",
        "productUri": "",
        "acceptExternalCommands": true,
        "maxAllowedSessionNumber": 10,
        "maxConnectionsPerEndpoint": 10,
        "maxAllowedSubscriptionNumber": 100,
        "alternateHostname": "",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "allowAnonymous": true,
        "individualCerts": false,
        "isAuditing": false,
        "serverDiscovery": true,
        "users": [],
        "xmlsetsOPCUA": [],
        "publicCertificateFile": "",
        "privateCertificateFile": "",
        "registerServerMethod": 1,
        "discoveryServerEndpointUrl": "",
        "capabilitiesForMDNS": "",
        "maxNodesPerRead": 1000,
        "maxNodesPerWrite": 1000,
        "maxNodesPerHistoryReadData": 100,
        "maxNodesPerBrowse": 3000,
        "maxBrowseContinuationPoints": 10,
        "maxHistoryContinuationPoints": 10,
        "delayToInit": 1000,
        "delayToClose": 200,
        "serverShutdownTimeout": 100,
        "addressSpaceScript": "function constructAlarmAddressSpace(server, addressSpace, eventObjects, done) {\n\n  const opcua = coreServer.choreCompact.opcua;\n  const LocalizedText = opcua.LocalizedText;\n  const namespace = addressSpace.getOwnNamespace();\n  \n  const Variant = opcua.Variant;\n  const DataType = opcua.DataType;\n  const DataValue = opcua.DataValue;\n  \n  let count=\"a\";\n  \n  coreServer.debugLog(\"init dynamic address space\");\n  const rootFolder = addressSpace.findNode(\"RootFolder\");\n  \n  node.warn(\"construct new address space for OPC UA\");\n  \n  const HBFG = namespace.addFolder(rootFolder.objects, {\n      \"browseName\":\"HBFG\"\n  });\n  \n  const Tanks = namespace.addFolder(HBFG,{ \"browseName\":\"Tanks\" });\n  \n  \nnamespace.addVariable({\n    \"componentof\": Tanks,\n    \"nodeId\": \"ns=1;s=count\",\n    \"browseName\":\"Counter\",\n    \"dataType\": \"String\",\n    \"value\": {\n      \"get\": function() {\n        return new Variant({\n          \"dataType\": DataType.String,\n          \"value\": count\n        });\n      },\n      \"set\": function(variant) {\n        count=parseFloat(variant.value);\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n  \n\n  coreServer.debugLog(\"create dynamic address space done\");\n  node.warn(\"construction of new address space for OPC UA done\");\n        \n  done();\n}\n",
        "x": 660,
        "y": 380,
        "wires": []
    },
    {
        "id": "d6af2ba71bd244b8",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://localhost:4840",
        "secpol": "None",
        "secmode": "None",
        "none": false,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    }
]

Does anybody know what I'm doing wrong? I'm relatively new to OPC UA and would appreciate the help. Thank you!

--edit: forgot to remove the "parsefloat()" in the set command. I can read the variable now. The issue with the writing client is still there though

Look examples folder and OPCUA-TEST-NODES.json Tab Write:

Item-node:
image