OPC UA Client Automatic Tag Discovery

I have OPC Server on KepServerEX. I would like to creat OPC UA Client using opc.tcp://127.0.0.1:49320 to discover all defined tags. I just want to not define nodeid of each node. Because I have more than 5000 tags to read. I am looking for whether there is short way or not. I also want to write all tags on MSSQL Database at the same time interval. Could you propose any solution for that?

I've also used KepServer
I saw and implemented the built-in "example" when installing KepServer.
KepServer is a great program. But the price is too expensive, so I can't use it after version 5.
I hope you can see the example and solve it like me.
It was nice to meet the same KepServer user, so I wrote a post.
I wish you success in developing KepServer linkage.

another way is.. Export all 5000 tags to csv file in KetServer . then you can read CSV in node-red

1 Like

Another solution could be browse (use crawler) to read all variables.
Then subscribe them by function node use msg.action = "subscribe", fill up topic & payload fields.

@mikakaraila I could not understand what you mean. Could you show on figure?

This is my flow btw.

[{"id":"95bc14a92641c230","type":"tab","label":"Flow 1","disabled":false,"info":"","env":},{"id":"1e5aa6cce54b8bda","type":"OpcUa-Item","z":"95bc14a92641c230","item":"{ns=2;s=Channel1.Device1.State.generate,ns=2;s=Channel1.Device1.Evet.denden}","datatype":"Float","value":"","name":"Tag","x":250,"y":200,"wires":[]},{"id":"f26cd983c4306e09","type":"inject","z":"95bc14a92641c230","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"10","topic":"","payload":"","payloadType":"str","x":90,"y":200,"wires":[["1e5aa6cce54b8bda"]]},{"id":"63cb32911f1618ea","type":"OpcUa-Client","z":"95bc14a92641c230","endpoint":"ac988fc93e931f7a","action":"read","deadbandtype":"a","deadbandvalue":1,"time":10,"timeUnit":"s","certificate":"n","localfile":"","localkeyfile":"","securitymode":"None","securitypolicy":"None","folderName4PKI":"","name":"Server","x":610,"y":140,"wires":[["e032291e848611b6"]]},{"id":"f1fb7580a88a6d71","type":"change","z":"95bc14a92641c230","name":"","rules":[{"t":"set","p":"myData","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":80,"wires":[["4d38d36579961769"]]},{"id":"8ae1c39b1c53a8de","type":"http in","z":"95bc14a92641c230","name":"","url":"/Channel1.Device1.generate","method":"get","upload":false,"swaggerDoc":"","x":150,"y":280,"wires":[["77be98553be54d5b"]]},{"id":"3aeadbbb4a730e13","type":"http response","z":"95bc14a92641c230","name":"","statusCode":"","headers":{},"x":570,"y":360,"wires":},{"id":"77be98553be54d5b","type":"change","z":"95bc14a92641c230","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"myData","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":340,"wires":[["743fcf824647a9aa"]]},{"id":"743fcf824647a9aa","type":"template","z":"95bc14a92641c230","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{"v": {{payload}}}","output":"json","x":380,"y":340,"wires":[["3aeadbbb4a730e13","1d3922a9b7e31f82"]]},{"id":"1d3922a9b7e31f82","type":"debug","z":"95bc14a92641c230","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":300,"wires":},{"id":"cea77679bca63644","type":"http request","z":"95bc14a92641c230","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://localhost:1880/Channel1.Device1.generate","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":290,"y":400,"wires":[[]]},{"id":"ec71ebcc22744f63","type":"inject","z":"95bc14a92641c230","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":400,"wires":[["cea77679bca63644"]]},{"id":"4d38d36579961769","type":"debug","z":"95bc14a92641c230","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1190,"y":60,"wires":[]},{"id":"960665b90a072393","type":"MSSQL","z":"95bc14a92641c230","mssqlCN":"719942175fc739d7","name":"","outField":"payload","returnType":0,"throwErrors":1,"query":"\r\n","modeOpt":"","modeOptType":"query","queryOpt":"topic","queryOptType":"msg","paramsOpt":"","paramsOptType":"editor","rows":"rows","rowsType":"msg","params":[],"x":420,"y":80,"wires":[["1dccebaf934bc23e"]]},{"id":"1dccebaf934bc23e","type":"debug","z":"95bc14a92641c230","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":80,"wires":[]},{"id":"7befdb5dc1c57364","type":"function","z":"95bc14a92641c230","name":"","func":"var tmpdate = new Date();\nvar date = tmpdate.getFullYear()+'-'+(tmpdate.getMonth()+1)+'-'+tmpdate.getDate()+" "+\ntmpdate.getHours()+':'+tmpdate.getMinutes()+':'+tmpdate.getSeconds()+'.'+tmpdate.getMilliseconds();\nvar device = msg.topic.split(";")[1].split("=")[1];\nvar value = msg.payload;\nmsg.topic = "INSERT INTO [dbo].[Tezgah] (DEVICE_ID,VALUE,DATE) VALUES ('"+device+"','"+value+"','"+date+"')";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":200,"y":80,"wires":[["960665b90a072393"]]},{"id":"9a027ba93628be9f","type":"inject","z":"95bc14a92641c230","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":520,"wires":[["18f9680b1f962590"]]},{"id":"18f9680b1f962590","type":"file in","z":"95bc14a92641c230","name":"","filename":"C:\Users\mert\Admin\x.xlsx","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":340,"y":520,"wires":[["6504258d874d9c04"]]},{"id":"5bc2f42307c5999f","type":"sheet","z":"95bc14a92641c230","name":"","sheetName":"Device1","x":110,"y":600,"wires":[["9a691fd12e977c6a"]]},{"id":"9a691fd12e977c6a","type":"sheet-to-json","z":"95bc14a92641c230","name":"","raw":"true","range":"A1:F3","header":"default","blankrows":false,"x":270,"y":600,"wires":[["7fbe89c8e8414393"]]},{"id":"6504258d874d9c04","type":"book","z":"95bc14a92641c230","name":"","raw":false,"x":610,"y":520,"wires":[["5bc2f42307c5999f"]]},{"id":"7fbe89c8e8414393","type":"change","z":"95bc14a92641c230","name":"","rules":[{"t":"set","p":"tags","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":600,"wires":[]},{"id":"1b3881d44233e9c6","type":"comment","z":"95bc14a92641c230","name":"Excel Read Tag","info":"","x":100,"y":480,"wires":},{"id":"ac31cc1207253551","type":"comment","z":"95bc14a92641c230","name":"Http Request","info":"","x":90,"y":240,"wires":},{"id":"0b1dc2f6a0e23a6f","type":"comment","z":"95bc14a92641c230","name":"OPC UA Read and Write Tag","info":"","x":140,"y":40,"wires":},{"id":"03b98a26d901164f","type":"inject","z":"95bc14a92641c230","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"tags","payloadType":"flow","x":100,"y":680,"wires":[["5779b27199016528"]]},{"id":"5779b27199016528","type":"debug","z":"95bc14a92641c230","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":680,"wires":},{"id":"e032291e848611b6","type":"debug","z":"95bc14a92641c230","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":140,"wires":},{"id":"c1dfab9ecd86b4a4","type":"function","z":"95bc14a92641c230","name":"","func":"var a = ;\nfor(let i = 0; i < msg.payload.length; i++){\n a.push("ns=2;s=" + msg.payload[i].TagName)\n}\nmsg.payload = a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":460,"y":140,"wires":[["63cb32911f1618ea"]]},{"id":"312ee7919b0c0d59","type":"change","z":"95bc14a92641c230","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"tags","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":140,"wires":[["c1dfab9ecd86b4a4"]]},{"id":"936b479562584041","type":"inject","z":"95bc14a92641c230","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":140,"wires":[["312ee7919b0c0d59"]]},{"id":"ac988fc93e931f7a","type":"OpcUa-Endpoint","endpoint":"opc.tcp://127.0.0.1:49320","secpol":"None","secmode":"None","login":false},{"id":"719942175fc739d7","type":"MSSQL-CN","tdsVersion":"7_4","name":"DB","server":"localhost","port":"1433","encyption":false,"trustServerCertificate":true,"database":"NodeRed","useUTC":true,"connectTimeout":"15000","requestTimeout":"15000","cancelTimeout":"5000","pool":"5","parseJSON":false,"enableArithAbort":true}]

When I could not fnd a way to browseall tags automatically, I put these tags on excel and read these tags. By storing these tags on flow variable (tags). I could create array in function node and add all tags with specified ns=2;s="from excel cell" and send it to OPC UA Client Node. I do not want to create OPC UA Item Node for each tag. Because it will be very difficult more than 5000 nodes. I also give OPC UA Item Node property like "{ns=2;s=Channel1.Device1.State.generate,ns=2;s=Channel1.Device1.Evet.denden}" but Item Node cannot accept item more tha one. I am looking for some node blocks directly connect OPC UA Server and find all tags on child folder but there is not enough information on the Internet. I hope that I could explain my problem clearly. If anyone suggest any way, I am open to discuss.
Thank you from now.

c

func

more

At the end, I want to do something like that.

Client node with browse action and inject root nodeId to read everything under it.

image

@mikakaraila Could you share your flow? I could try to analyze it.

It is in the examples OPCUA-TEST-NODES.json, look Browse Simulation