# OPC UA Client Automatic Tag Discovery

**URL:** <https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968>\
**Category:** Industrial\
**Tags:** database\
**Created:** [15 June 2022 11:01 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968 "2022-06-15T11:01:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mert](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mert](https://discourse.nodered.org/u/mert)\
**Post date:** [15 June 2022 11:01 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/1 "2022-06-15T11:01:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![simmani5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/simmani5/32/57008_2.png) [@simmani5](https://discourse.nodered.org/u/simmani5)\
**Post date:** [15 June 2022 11:13 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/2 "2022-06-15T11:13:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![simmani5](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/simmani5/32/57008_2.png) [@simmani5](https://discourse.nodered.org/u/simmani5)\
**Post date:** [15 June 2022 11:25 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/3 "2022-06-15T11:25:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mikakaraila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikakaraila/32/37496_2.png) [@mikakaraila](https://discourse.nodered.org/u/mikakaraila)\
**Post date:** [20 June 2022 16:25 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/4 "2022-06-20T16:25:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mert](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mert](https://discourse.nodered.org/u/mert)\
**Post date:** [20 June 2022 19:19 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/5 "2022-06-20T19:19:57Z")

</div>

@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](http://localhost:1880/Channel1.Device1.generate%22,%22tls%22:%22%22,%22persist%22:false,%22proxy%22:%22%22,%22authType%22:%22%22,%22senderr%22:false,%22x%22:290,%22y%22:400,%22wires%22:%5B%5B%5D%5D%7D,%7B%22id%22:%22ec71ebcc22744f63%22,%22type%22:%22inject%22,%22z%22:%2295bc14a92641c230%22,%22name%22:%22%22,%22props%22:%5B%7B%22p%22:%22payload%22%7D,%7B%22p%22:%22topic%22,%22vt%22:%22str%22%7D%5D,%22repeat%22:%22%22,%22crontab%22:%22%22,%22once%22:false,%22onceDelay%22:0.1,%22topic%22:%22%22,%22payload%22:%22%22,%22payloadType%22:%22date%22,%22x%22:100,%22y%22:400,%22wires%22:%5B%5B%22cea77679bca63644%22%5D%5D%7D,%7B%22id%22:%224d38d36579961769%22,%22type%22:%22debug%22,%22z%22:%2295bc14a92641c230%22,%22name%22:%22%22,%22active%22:true,%22tosidebar%22:true,%22console%22:false,%22tostatus%22:false,%22complete%22:%22payload%22,%22targetType%22:%22msg%22,%22statusVal%22:%22%22,%22statusType%22:%22auto%22,%22x%22:1190,%22y%22:60,%22wires%22:%5B%5D%7D,%7B%22id%22:%22960665b90a072393%22,%22type%22:%22MSSQL%22,%22z%22:%2295bc14a92641c230%22,%22mssqlCN%22:%22719942175fc739d7%22,%22name%22:%22%22,%22outField%22:%22payload%22,%22returnType%22:0,%22throwErrors%22:1,%22query%22:%22%5Cr%5Cn%22,%22modeOpt%22:%22%22,%22modeOptType%22:%22query%22,%22queryOpt%22:%22topic%22,%22queryOptType%22:%22msg%22,%22paramsOpt%22:%22%22,%22paramsOptType%22:%22editor%22,%22rows%22:%22rows%22,%22rowsType%22:%22msg%22,%22params%22:%5B%5D,%22x%22:420,%22y%22:80,%22wires%22:%5B%5B%221dccebaf934bc23e%22%5D%5D%7D,%7B%22id%22:%221dccebaf934bc23e%22,%22type%22:%22debug%22,%22z%22:%2295bc14a92641c230%22,%22name%22:%22%22,%22active%22:true,%22tosidebar%22:true,%22console%22:false,%22tostatus%22:false,%22complete%22:%22true%22,%22targetType%22:%22full%22,%22statusVal%22:%22%22,%22statusType%22:%22auto%22,%22x%22:610,%22y%22:80,%22wires%22:%5B%5D%7D,%7B%22id%22:%227befdb5dc1c57364%22,%22type%22:%22function%22,%22z%22:%2295bc14a92641c230%22,%22name%22:%22%22,%22func%22:%22var) 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}]

---

<div class="post-metadata">

**Author:** ![mert](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mert](https://discourse.nodered.org/u/mert)\
**Post date:** [20 June 2022 19:45 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/6 "2022-06-20T19:45:15Z")

</div>

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.

 ![excel](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/8/3890a80dfa752afe9c481d1da6a27004c944aca0.png)

 ![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/04cf0c2fc718804b7cfacc8364e9927555e344fd.png)

![c](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/78b5d34ca9f47507d91b89293d45fc31c5f9a6b7.png)

 ![f1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3e7f3ccd1d67004873aaf9fd6d1cdf59b0f0baba.png)

![func](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a464c58a6271ab4b9fd6def33194e18cc4ab677c.png)

---

<div class="post-metadata">

**Author:** ![mert](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mert](https://discourse.nodered.org/u/mert)\
**Post date:** [20 June 2022 19:51 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/7 "2022-06-20T19:51:20Z")

</div>

![more](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/f/8fe16c98c476602b1ad69c2770567194c52233b2.png)

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

 ![final](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fa5e970f6337f4ee107e4a4ce96e35b250fc5ba2.png)

---

<div class="post-metadata">

**Author:** ![mikakaraila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikakaraila/32/37496_2.png) [@mikakaraila](https://discourse.nodered.org/u/mikakaraila)\
**Post date:** [21 June 2022 04:54 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/8 "2022-06-21T04:54:36Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c02c2a6aac294e612c20ebb0151cd58c8524fdcc.png)

---

<div class="post-metadata">

**Author:** ![mert](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@mert](https://discourse.nodered.org/u/mert)\
**Post date:** [21 June 2022 05:28 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/9 "2022-06-21T05:28:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mikakaraila](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikakaraila/32/37496_2.png) [@mikakaraila](https://discourse.nodered.org/u/mikakaraila)\
**Post date:** [21 June 2022 05:41 UTC](https://discourse.nodered.org/t/opc-ua-client-automatic-tag-discovery/63968/10 "2022-06-21T05:41:57Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/937b5eddc5cfb1f5f35eeebae32788575e4189dd.png)
