OPC UA server giving “TypeError: Cannot read properties of undefined (reading ‘indexOf’)”

Hi,
I am using node-red-contrib-opcua. I tried to create opcua server using this library. but, when I inject the data, it gives error TypeError: Cannot read properties of undefined (reading ‘indexOf’).
I cannot figure out what is wrong.

What are you injecting?

I have had an experiment as this ,may this help you.
OPC UA

The code is here

[
    {
        "id": "b508aa4f81d0d6ea",
        "type": "tab",
        "label": "娴佺▼ 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "ce47e8b78311a345",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://localhost:54840",
        "secpol": "None",
        "secmode": "None",
        "none": true,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    },
    {
        "id": "9fbb37bba5b5057d",
        "type": "modbus-client",
        "name": "",
        "clienttype": "simpleser",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": true,
        "tcpHost": "127.0.0.1",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyS4",
        "serialType": "RTU",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": 1,
        "commandDelay": 1,
        "clientTimeout": 1000,
        "reconnectOnTimeout": true,
        "reconnectTimeout": 2000,
        "parallelUnitIdsAllowed": true,
        "showWarnings": true,
        "showLogs": true
    },
    {
        "id": "e950412533eed178",
        "type": "debug",
        "z": "b508aa4f81d0d6ea",
        "name": "debug 1",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 140,
        "wires": []
    },
    {
        "id": "f0c0776d21bf79f7",
        "type": "OpcUa-Client",
        "z": "b508aa4f81d0d6ea",
        "endpoint": "ce47e8b78311a345",
        "action": "write",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "folderName4PKI": "",
        "name": "鍐欏叆鏈嶅姟鍣?,
        "x": 410,
        "y": 140,
        "wires": [
            [
                "e950412533eed178"
            ]
        ]
    },
    {
        "id": "9c741f3ac1bfd2a9",
        "type": "OpcUa-Item",
        "z": "b508aa4f81d0d6ea",
        "item": "ns=1;s=pressure",
        "datatype": "Double",
        "value": "",
        "name": "",
        "x": 420,
        "y": 60,
        "wires": [
            [
                "f0c0776d21bf79f7"
            ]
        ]
    },
    {
        "id": "4f42326772323433",
        "type": "OpcUa-Item",
        "z": "b508aa4f81d0d6ea",
        "item": "ns=1;s=pressure",
        "datatype": "Double",
        "value": "",
        "name": "",
        "x": 240,
        "y": 380,
        "wires": [
            [
                "dce8b173b8cf3390"
            ]
        ]
    },
    {
        "id": "dce8b173b8cf3390",
        "type": "OpcUa-Client",
        "z": "b508aa4f81d0d6ea",
        "endpoint": "ce47e8b78311a345",
        "action": "read",
        "deadbandtype": "a",
        "deadbandvalue": 1,
        "time": 10,
        "timeUnit": "s",
        "certificate": "n",
        "localfile": "",
        "localkeyfile": "",
        "securitymode": "None",
        "securitypolicy": "None",
        "folderName4PKI": "",
        "name": "浠庢湇鍔″櫒璇?,
        "x": 450,
        "y": 340,
        "wires": [
            [
                "6d2b8f5608e9db13"
            ]
        ]
    },
    {
        "id": "903b5b2dfdc6bb06",
        "type": "inject",
        "z": "b508aa4f81d0d6ea",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "2",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 180,
        "y": 280,
        "wires": [
            [
                "4f42326772323433"
            ]
        ]
    },
    {
        "id": "6d2b8f5608e9db13",
        "type": "debug",
        "z": "b508aa4f81d0d6ea",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 240,
        "wires": []
    },
    {
        "id": "bb1c6ccd1a959c23",
        "type": "opcua-compact-server",
        "z": "b508aa4f81d0d6ea",
        "port": 54840,
        "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  // server = the created node-opcua server\n  // addressSpace = address space of the node-opcua server\n  // eventObjects = add event variables here to hold them in memory from this script\n\n  // internal sandbox objects are:\n  // node = the compact server node,\n  // coreServer = core compact server object for debug and access to NodeOPCUA\n  // this.sandboxNodeContext = node context node-red\n  // this.sandboxFlowContext = flow context node-red\n  // this.sandboxGlobalContext = global context node-red\n  // this.sandboxEnv = env variables\n  // timeout and interval functions as expected from nodejs\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  var flexServerInternals = this;\n\n  this.sandboxFlowContext.set(\"pressure\", 0);\n\n  coreServer.debugLog(\"init dynamic address space\");\n  const rootFolder = addressSpace.findNode(\"RootFolder\");\n\n  const myDevice = namespace.addFolder(rootFolder.objects, {\n    \"browseName\": \"PN6400\"\n  });\n  const gpioFolder = namespace.addFolder(myDevice, { \"browseName\": \"parameters inputs\" });\n  const isoInputs = namespace.addFolder(gpioFolder, {\n    \"browseName\": \"Inputs\"\n  });\n\n  const paraInput = namespace.addVariable({\n    \"organizedBy\": isoInputs,\n    \"browseName\": \"pressure\",\n    \"nodeId\": \"ns=1;s=pressure\",\n    \"dataType\": \"Double\",\n    \"value\": {\n      \"get\": function () {\n        return new Variant({\n          \"dataType\": DataType.Double,\n          \"value\": flexServerInternals.sandboxFlowContext.get(\"pressure\")\n        });\n      },\n      \"set\": function (variant) {\n        flexServerInternals.sandboxFlowContext.set(\n          \"pressure\",\n          parseFloat(variant.value)\n        );\n        return opcua.StatusCodes.Good;\n      }\n    }\n  });\n\n  //------------------------------------------------------------------------------\n  // Add a view\n  //------------------------------------------------------------------------------\n  const viewDI = namespace.addView({\n    \"organizedBy\": rootFolder.views,\n    \"browseName\": \"PN6400-In\"\n  });\n  viewDI.addReference({\n    \"referenceType\": \"Organizes\",\n    \"nodeId\": paraInput.nodeId\n  });\n  done();\n}\n",
        "x": 420,
        "y": 240,
        "wires": []
    },
    {
        "id": "078da5faf0d4c676",
        "type": "modbus-read",
        "z": "b508aa4f81d0d6ea",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "6",
        "dataType": "HoldingRegister",
        "adr": "0",
        "quantity": "1",
        "rate": "2",
        "rateUnit": "s",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "9fbb37bba5b5057d",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 110,
        "y": 200,
        "wires": [
            [
                "77b09260f0d695a7"
            ],
            [
                "b8be7f31e27c5ca2"
            ]
        ]
    },
    {
        "id": "77b09260f0d695a7",
        "type": "modbus-response",
        "z": "b508aa4f81d0d6ea",
        "name": "鐩戝惉",
        "registerShowMax": 20,
        "x": 270,
        "y": 180,
        "wires": []
    },
    {
        "id": "b8be7f31e27c5ca2",
        "type": "function",
        "z": "b508aa4f81d0d6ea",
        "name": "瑙f瀽鍘嬪姏鍊?,
        "func": "msg.payload = msg.payload.data[0];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 230,
        "y": 60,
        "wires": [
            [
                "9c741f3ac1bfd2a9"
            ]
        ]
    }
]

Thank you. I will check

Cannot see topic in the message...??

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