How to get live opc-ua node's value from cumulocity IoT plattform?

Product/components used and version/fix level:

Comulocity IoT

Detailed explanation of the problem:

Dear support team,

I am Yuanfeng Tian, a master student of Computational Engineering at TU Darmstadt. I am working as the research assistant (Hiwi after Yumao Liu) at the Institute PLCM. I need to get information like “True” from nodes to make a custom verify widget.

Refers Question: (https://tech.forums.softwareag.com/t/how-to-read-live-nodes-values-from-opc-ua-server/265130)

I write some codes like below
Code in Component.ts (readnode function,which will be used in html) :

readnode(ns: number, i: number)  {
        let formData = `{ 
            "deviceId": "replaceID", 
            "c8y_ua_command_ReadValue": 
            {"nodes": ["ns=replacens;i=replacei"],
            "timestampsToReturn" : "Both"}, 
            "description": "Read value from node" 
        }`;
        formData = formData.replace("replaceID", this.deviceID)
        formData = formData.replace("replacens", String(ns))
        formData = formData.replace("replacei", String(i))
        let formDataJSON = JSON.parse(formData)
        // let formDataJSON = eval("("+formData+")");
        this.http.post(this.url, formDataJSON, this.options).subscribe(res => {
            // Parse the JSON string in the 'result' field.
            const result = JSON.parse(res['c8y_Command']['result']);
          
            // Extract the value of the node.
            const nodeValue = result['results']['ns=2;i=47']['13']['value']['value'];
            
            this.showContent = true //(nodeValue == 'true');
            this.loginfailed = !this.showContent;
            
            console.log(res);
            console.log(nodeValue);
          });
          alert(this.message);
        }

HTML:

    <div *ngIf="showContent; else loginTemplate">
      <p>Welcome to my widget!</p>
 
<ng-template #loginTemplate>
 <p *ngIf="loginFailed">Invalid username or password.</p>
    <div class="container">
    <label class="u-label">Check authentication: </label>
    <button class="button" [disabled]="canClick" (click)="readnode(2,47)">Check</button>
  </div>
</ng-template>

It looks like below:
<ng-template #loginTemplate>

Invalid username or password.

Check authentication: Check

In component.ts, in order to test the function, i set the ‘showcontent’ to true when i click “check” button. But it doesn’t work and show the error like below. Failure reason is ‘GOOD’ but status failed and I can not get the information from this node. Could you tell me how to fix it?

Best regards,
Tian,Yuanfeng

Error messages / full error message screenshot / log file:

Question related to a free trial, or to a production (customer) instance?

We are IoTEP user. This is our tenat ID: bulut-dik-2021

Could you please provide the log of the Cumulocity OPC UA Gateway?

2023-06-26 14:14:29.097 ERROR 1159 --- [ool-31-thread-3] com.cumulocity.opcua.client.NodeIds      : Unable to convert nodeId with ns uri to nodeId, most probably the nodeId string contains server index!

org.opcfoundation.ua.common.ServiceResultException: Bad_UnexpectedError (code=0x80010000, description="Index for uri "http://xuanqiao.freeopcua.github.io" not found in NamespaceTable")
	at org.opcfoundation.ua.common.NamespaceTable.toNodeId(NamespaceTable.java:135)
	at com.cumulocity.opcua.client.NodeIds.toNodeId(NodeIds.java:356)
	at com.cumulocity.opcua.client.gateway.subscription.SubscriptionDataResolver.resolveData(SubscriptionDataResolver.java:102)
	at com.cumulocity.opcua.client.gateway.subscription.SubscriptionDataResolver.resolve(SubscriptionDataResolver.java:73)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.subscribeWithDeviceTypeAndNode(UpdateServerSubscriptionTask.java:194)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.updateSubscriptionForMappedNode(UpdateServerSubscriptionTask.java:164)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.updateSubscriptionForServer(UpdateServerSubscriptionTask.java:142)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.run(UpdateServerSubscriptionTask.java:100)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

Hello Alexander,

thanks for your reply
Are those information enough?

2023-06-26 14:14:29.097 ERROR 1159 --- [ool-31-thread-3] com.cumulocity.opcua.client.NodeIds      : Unable to convert nodeId with ns uri to nodeId, most probably the nodeId string contains server index!

org.opcfoundation.ua.common.ServiceResultException: Bad_UnexpectedError (code=0x80010000, description="Index for uri "http://xuanqiao.freeopcua.github.io" not found in NamespaceTable")
	at org.opcfoundation.ua.common.NamespaceTable.toNodeId(NamespaceTable.java:135)
	at com.cumulocity.opcua.client.NodeIds.toNodeId(NodeIds.java:356)
	at com.cumulocity.opcua.client.gateway.subscription.SubscriptionDataResolver.resolveData(SubscriptionDataResolver.java:102)
	at com.cumulocity.opcua.client.gateway.subscription.SubscriptionDataResolver.resolve(SubscriptionDataResolver.java:73)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.subscribeWithDeviceTypeAndNode(UpdateServerSubscriptionTask.java:194)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.updateSubscriptionForMappedNode(UpdateServerSubscriptionTask.java:164)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.updateSubscriptionForServer(UpdateServerSubscriptionTask.java:142)
	at com.cumulocity.opcua.client.gateway.subscription.UpdateServerSubscriptionTask.run(UpdateServerSubscriptionTask.java:100)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

Hello Alexander,

thanks for your reply
Are those information enough?

Could please check your OPC UA server with another OPC UA client like UA Expert if the OPC UA server you use has this node id? It seems to me that index URI (“http://xuanqiao.freeopcua.github.io”) is not available at your server…

Hello Alexander,

xuanqiao.freeopcua.github.io is another uri of my college’s opcua server. And http://authentyf.freeopcua.github.io is the uri which I use. But I don’t really know why that shows in the gateway log. We build several server for a same aiming IP to test different function(Maybe this is the reason).
I check the namespace in cumulocity and find the node ns=2 i=47 in this. And I can also control my device as picture shown below

Be aware that the index of the name space isn’t necessarily fix. Could you check your namespace table of your OPC UA Server if it uses index 2 (“ns=2”) for “http://authentyf.freeopcua.github.io”. I am not 100% but i think you can also use instead of “ns=2;i=5” the name space directly, “nsu=http://authentyf.freeopcua.github.io;i=5” in the node id array of the read operation. However, i am wondering why you change the namespace URIs. If the node has a specific semantic and belongs to a specific domain name space, the namespace URI shouldn’t changed.

HalloAlexander,

thanks for your advice. I deleted some servers and keep only one server with uri:(http://xuanqiao.freeopcua.github.io/). I tried again and there are no more Error which happens like previous picture.But it still failed. Below is the log of gateway

:smiley:anyone knows how to solve this?