Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Receiving Error message event BadAttributeIdInvalid

More
17 Sep 2020 09:35 #8904 by support
Hello,
thank you for update. I am glad it works now.

It is possible that the BadAttributeIdInvalid error had to do with an attribute related to the event source used originally, and the proper event source does not have the problem. I have expanded the error message (in upcoming QuickOPC 2020.3 version) so that it will list the actual node Id and attribute Id, for better troubleshooting, if something like this happens in the future.

The BadUserAccessDenied error is a separate thing, and is not surprising. It is quite possible that parts of the server's information model require user authentication, while other parts don't. In this case, the error message and the resolution were straightforward I think.

Best regards

Please Log in or Create an account to join the conversation.

More
15 Sep 2020 09:55 #8898 by Chiara-Dea
Ok, I managed to get some events displayed on the console. I'll update how I did.

The first thing I tried was, as you suggested, to pass an eventFilter with less field - it was no use, the same error appeared.

So I took a step back and tryied to Browse event source like in this example .
The result was the following:
Event sources:
- Sinumerik -> nsu=SinumerikVarProvider ;ns=2;s=Sinumerik (Object)

I use this event source in the function like this:
UANodeElementCollection eventSourceNodeElementCollection = client.BrowseEventSources(endpointDescriptor, UAObjectIds.Server);
UANodeElement eventSource = eventSourceNodeElementCollection.First();
 
 
            client.EventNotification += client_EventNotification;
 
            Console.WriteLine("Subscribing...");
            client.SubscribeEvent(endpointDescriptor, eventSource, 1000, new UAAttributeFieldCollection 
            {
                Operands.NodeId,
                    Operands.EventId,
                    Operands.EventType,
                    Operands.SourceNode,
                    Operands.SourceName,
                    Operands.Time,
                    Operands.ReceiveTime,
                    Operands.LocalTime,
                    Operands.Message,
                    Operands.Severity,
            });

The output was a weird BadUserAccessDenied (and I set up the username and password in the descriptor).

So I searched again in forum and docs and found that I need to create the UserIdentity like this:
// Define which server we will work with.
UAEndpointDescriptor endpointDescriptor = "opc.tcp://<ip>:<port>";
endpointDescriptor.UserIdentity = UserIdentity.CreateUserNameIdentity(<the username>, <the password>);
endpointDescriptor.UserName = <the username>;
endpointDescriptor.Password = <the password>;
And then I was able (by passing the eventSourceNode in the subscription) to receive the correct notifications!

The final output:
Starting test...
Browsing event sources
 
Event sources:
- Sinumerik -> nsu=SinumerikVarProvider ;ns=2;s=Sinumerik (Object)
Subscribing...
[] Success
Processing event notifications for 30 seconds...
[] Success; (10 field results) [PLC] 500! "700046 | Please perform safety check" @9/14/2020 11:25:41 AM
[] Success; (10 field results) [PLC] 500! "700833 | SQG6C1: high level prewarning in foundation tank" @9/14/2020 12:38:12 PM
[] Success; (10 field results) [PLC] 500! "700139 | BB22C: APU fault" @9/14/2020 1:27:47 PM
[] Success; (10 field results) [PLC] 500! "700332 | SPG3A: Table hydrostatics filter not OK" @9/14/2020 1:27:55 PM
[] Success; Refresh; RefreshInitiated
[] Success; Refresh; (10 field results) [PLC] 500! "700046 | Please perform safety check" @9/14/2020 11:25:41 AM
[] Success; Refresh; (10 field results) [PLC] 500! "700833 | SQG6C1: high level prewarning in foundation tank" @9/14/2020 12:38:12 PM
[] Success; Refresh; (10 field results) [PLC] 500! "700139 | BB22C: APU fault" @9/14/2020 1:27:47 PM
[] Success; Refresh; (10 field results) [PLC] 500! "700332 | SPG3A: Table hydrostatics filter not OK" @9/14/2020 1:27:55 PM
[] Success; Refresh; RefreshComplete
Unsubscribing...
Waiting for 5 seconds...
Test ended. Press any key to quit.

BTW, why is it that you cannot use the debugger?

It's because I'm working remotely and due to client policy I cannot directly connect to the OPCUA server with a developement machine.

Thanks for helping!

Please Log in or Create an account to join the conversation.

More
11 Sep 2020 17:57 #8886 by support
Thank, this has helped somewhat.
BTW, why is it that you cannot use the debugger?

Anyway, the likely cause is that some of the event fields that are being subscribed to by the code are not supported by the server. This is weird, because the default setting uses fields that should generally exist. Your SubscribeEvent call internally transforms to:
SubscribeEvent(
                endpointDescriptor:endpointDescriptor,
                nodeDescriptor:nodeDescriptor,
                samplingInterval:samplingInterval, 
                eventFilter:UABaseEventObject.AllFields,
                eventCallback:eventCallback, 
                state:state)

and UABaseEventObject.AllFields is defined like this:
new UAAttributeFieldCollection
                {
                    Operands.NodeId,
 
                    Operands.EventId,
                    Operands.EventType,
                    Operands.SourceNode,
                    Operands.SourceName,
                    Operands.Time,
                    Operands.ReceiveTime,
                    Operands.LocalTime,
                    Operands.Message,
                    Operands.Severity,
                }
You can try passing in eventFilter will less fields - start with the things you are really interested in - and see if that helps.

The other way to find out more details about what's happening would be to get a Wireshark trace of the communication: kb.opclabs.com/Collecting_information_for_troubleshooting .

Best regards

Please Log in or Create an account to join the conversation.

More
10 Sep 2020 07:26 #8880 by Chiara-Dea
I cannot use the debugger but I edited the example to have the exception and stacktrace printed.

Here is the result:
[] *** Failure Opc.UA.ServiceResult=0x80350000: OPC-UA service result - An error specific to OPC-UA service occurred (status code: BadAttributeIdInvalid). Details follow. [...]
Exception: OpcLabs.EasyOpc.UA.UAServiceException: OPC-UA service result - An error specific to OPC-UA service occurred (status code: BadAttributeIdInvalid). Details follow.
---- SERVICE RESULT ----
Status Code: {BadAttributeIdInvalid} = 0x80350000 (2150957056)
 
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.UpdateMonitoredItemsException(IEnumerable`1 monitoredItems)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.InternalPerformSdkSubscriptionChanges(IEnumerable`1 itemsToRemove, IEnumerable`1 itemsToModify, IEnumerable`1 itemsToAdd)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.PerformSdkSubscriptionChanges(IEnumerable`1 itemsToRemove, IEnumerable`1 itemsToModify, IEnumerable`1 itemsToAdd)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.ManipulateSdkSubscription(IEnumerable`1 itemsToRemove, IEnumerable`1 itemsToModify, IEnumerable`1 itemsToAdd)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.InternalConnect()
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.Connect()
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSessionBase.<>c__DisplayClass147_0.<ConnectSubscriptions>b__0()
   at OpcLabs.EasyOpc.UA.Toolkit.UAEngineBase.PerformGuardedOperation(String name, Action action)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSessionBase.ConnectSubscriptions(IEnumerable`1 clientSubscriptions)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSessionBase.<>c__DisplayClass145_0.<BeginConnectSubscriptions>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   at System.Threading.Tasks.Task.ExecuteEntryUnsafe(Thread threadPoolThread)
   at System.Threading.Tasks.Task.ExecuteFromThreadPool(Thread threadPoolThread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
 
Stacktrace:    at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.UpdateMonitoredItemsException(IEnumerable`1 monitoredItems)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.InternalPerformSdkSubscriptionChanges(IEnumerable`1 itemsToRemove, IEnumerable`1 itemsToModify, IEnumerable`1 itemsToAdd)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.PerformSdkSubscriptionChanges(IEnumerable`1 itemsToRemove, IEnumerable`1 itemsToModify, IEnumerable`1 itemsToAdd)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.ManipulateSdkSubscription(IEnumerable`1 itemsToRemove, IEnumerable`1 itemsToModify, IEnumerable`1 itemsToAdd)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.InternalConnect()
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSubscriptionBase.Connect()
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSessionBase.<>c__DisplayClass147_0.<ConnectSubscriptions>b__0()
   at OpcLabs.EasyOpc.UA.Toolkit.UAEngineBase.PerformGuardedOperation(String name, Action action)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSessionBase.ConnectSubscriptions(IEnumerable`1 clientSubscriptions)
   at OpcLabs.EasyOpc.UA.Toolkit.ClientServer.UAClientSessionBase.<>c__DisplayClass145_0.<BeginConnectSubscriptions>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   at System.Threading.Tasks.Task.ExecuteEntryUnsafe(Thread threadPoolThread)
   at System.Threading.Tasks.Task.ExecuteFromThreadPool(Thread threadPoolThread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Please Log in or Create an account to join the conversation.

More
09 Sep 2020 16:51 #8879 by support
Thank you.
Can you place a breakpoint to the beginning of the "client_EventNotification event" handler, and examine the "EasyUAEventNotificationEventArgs e" argument during the second event?

There will be a non-zero e.Exception property. Please post here its full error message (what gets printed in the example is intentionally shortened - but the "[...]" part indicates that there is something more), and also e.Exception.StackTrace. If there is a non-null e.Exception.InnerException, please post here its full message and stack trace as well, and so on.

Many thanks

Please Log in or Create an account to join the conversation.

More
09 Sep 2020 16:08 #8878 by Chiara-Dea
Ok, I'll answer each question here:

what OPC server are you connecting to?

It's a SinumerikServer

Does it actually support OPC UA Alarms&Conditions?

It is, I've tested it with a working tool and I receive both alarms and events from the machine (filters not ok, door open, etc).

Please Log in or Create an account to join the conversation.

More
09 Sep 2020 15:35 #8877 by support
Hello,

what OPC server are you connecting to?

Does it actually support OPC UA Alarms&Conditions?

Best regards

Please Log in or Create an account to join the conversation.

More
09 Sep 2020 13:57 #8876 by Chiara-Dea
Hello!
I've searched my issue through the forum and I found nothing.

I'm trying to connect to OPC UA and read Alarms&Conditions.

I made a .NET Core console application based on the example on the documentation OPC UA Alarms&Conditions - Retrieve fields from event data , editing the configuration parameter using the machine endpoint and adding a username and password, like this:
// Define which server we will work with.
UAEndpointDescriptor endpointDescriptor = "opc.tcp://<ip>:<port>";
endpointDescriptor.UserName = <the username>;
endpointDescriptor.Password = <the password>;
The rest of the code is the same as in the example.

I can connect to the machine, I heve the certificates in the correct place. But the output is the following:
Starting test...
Subscribing...
Processing event notifications for 30 seconds...
[] Success
[] *** Failure Opc.UA.ServiceResult=0x80350000: OPC-UA service result - An error specific to OPC-UA service occurred (status code: BadAttributeIdInvalid). Details follow. [...]
Unsubscribing...
Waiting for 5 seconds...
Test ended. Press any key to quit.

Am I missing something in the configuration or in creating the subscription?

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.069 seconds