Professional OPC
Development Tools

logos

Cleaning of the apartment All this is well suited to my kitchen. It will look good in my apartment.

More
10 Feb 2016 13:18 #3827 by sun21

support wrote: ...
Note that the issue you reported is still a valid issue - the call to SubscribeXXXX should not block in this way, and we will investigate it. ...


Dear Support,

Is there some news about the issue? It seems I'm still experiencing it when my network failing me like in this case:
"[2/10/2016 1:23:11 AM] [OpcNodesBrowser] UAException: An OPC-UA operation failure with error code -1 (0xFFFFFFFF) occurred, originating from ''. The inner exception, of type 'OpcLabs.EasyOpc.UA.Engine.UAClientEngineException', contains details about the problem.
InnerException: Timeout connecting the OPC-UA client session. The total timeout value was 60000 milliseconds, and we have waited for 59968 milliseconds. The actual waiting time is lower than the total timeout (or even zero) if the connection operation has already started earlier."
After this message my service has stalled and I had to kill it.

Serge

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

More
27 Aug 2015 15:42 #3525 by sun21
Thank you for your help. It works as you said, no need to re-subscribe. Thank you.

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

More
27 Aug 2015 14:16 - 27 Aug 2015 14:17 #3524 by support
Yes, precisely so.

Call to SubscribeXXXX indicates your permanent intent to be subscribed, which only ends if you call UnsubscribeXXXX. In between the Subscribe/Unsubscribe call pair, QuickOPC will *permanently* attempt to be and stay subscribed. The item or the server may be inaccessible at the moment of initial Subscribe, or become inaccessible at any later point - that should make no difference. QuickOPC will signal the problem to you, but after a configurable period, it will attempt to recover, and so on.

Think about it this way: Let's say you want to create a logger, or an HMI screen, with QuickOPC. You simply need to "subscribe" to the items you are interested in, and then process the event notifications. That's it. You will receive good values, or you will receive error indications, and you will log them or display them as they come. No reconnection code whatsoever is needed.

Note that the issue you reported is still a valid issue - the call to SubscribeXXXX should not block in this way, and we will investigate it. But I want, at the same time, steer you to a proper solution with regard to failure handling, which should make your code much shorter - and at the same time, the original issue is likely to go away.
Last edit: 27 Aug 2015 14:17 by support. Reason: correct typos

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

More
27 Aug 2015 14:02 #3523 by sun21
You mean that I can just wait some time and failed subscription will be restored automatically?

So it is not necessary to re-subscribe when I see in "MonitoredItemChangedEvent" (e.Succeeded == false) or (e.Exception != null) ?

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

More
27 Aug 2015 13:37 #3522 by support
Why are you trying to unsubscribe and re-subscribe? QuickOPC already contains retrial mechanisms that do all of that for you.

More info: E.g. the "Concepts" document, section "Best Practices", the very first chapter: "Do not write any code for OPC failure recovery", or www.opclabs.com/resources/product-information/articles/1048-best-practices-with-quickopc .

Best regards

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

More
27 Aug 2015 06:20 #3519 by support
Thank you for the detailed steps. We will attempt to reproduce it here.

Best regards

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

More
26 Aug 2015 16:16 - 27 Aug 2015 06:21 #3518 by sun21
Step by step how to trigger the problem:

1. I subscribed to ~400 OPC tags, callback MonitoredItemChangedEvent(..) is working well.

2. I stop Kepserver service (on different PC in the same network).

3. In the callback I fill in List<long> failedSubscriptionHandles:
void MonitoredItemChangedEvent(object self, EasyUAMonitoredItemChangedEventArgs e) { 
      if ((e.Succeeded && e.Exception == null)) {
           // store the VQT
      } else {
           long handle = (long)e.Arguments.State;
           lock (this)
           {
               if (!failedSubscriptionHandles.Contains(handle))
               {
                   failedSubscriptionHandles.Add(handle); // these items will be unsubscribed
               }
           }
      }

4. In the Timer callback I unsubscribe and re-subscribe:
void RefreshFailedSubscriptionsCallback(object sender, ElapsedEventArgs eargs)
        {
            lock (this)
            {
                try
                {
                    this.retryUnsubscribedItems.Enabled = false;
 
                    // Stop failed subscriptions
                    if (failedSubscriptionHandles.Count > 0)
                    {
                        StopMonitoringItems(failedSubscriptionHandles.ToList<long>());
                    }
 
                    // Re-subscribe items that are not subscribed yet (because of a subscription failure)
                    if (IsMonitoring)
                    {
                        IList<long> handlesToSubscribe = new List<long>();
                        foreach (KeyValuePair<long, DataItem.DataItem> dataItem in dataItems)
                        {
                            if (!dataItemHandleMappings.ContainsKey(dataItem.Key))
                            {
                                handlesToSubscribe.Add(dataItem.Key);
                            }
                        }
 
                        if (handlesToSubscribe.Count > 0)
                        {
                            StartMonitoringItems(handlesToSubscribe); // <<<<<<<<<<<< 
                        }
                    }
 
                }
                catch (Exception e)
                {
                    logger.Log("[OpcDataCollector] Exception: " + e.Message, Log.LogType.Error);
                }
 
                this.retryUnsubscribedItems.Enabled = true;
            }
        }

5. in StartMonitoringItems(handlesToSubscribe) I step to SubscribeMultipleMonitoredItems and it does not return:
// Select data items to start monitoring (all items must be added to the dataItems list)
        private void StartMonitoringItems(IEnumerable<long> dataItemHandles)
        {
            IList<EasyUAMonitoredItemArguments> easyUAMonitoredItemArguments = new List<EasyUAMonitoredItemArguments>();
            foreach (long dataItemHandle in dataItemHandles)
            {
                DataItem.DataItem dataItem = dataItems[dataItemHandle];
                dataItem.SubscriptionParametersChangedEvent += DataItemSubscriptionParametersChanged;
                UANodeDescriptor nodeDescriptor = new UANodeDescriptor(dataItem.ToNodeID());
                easyUAMonitoredItemArguments.Add(
                    new EasyUAMonitoredItemArguments(MonitoredItemChangedEvent,
                        dataItemHandle,
                        endPointDescriptor,
                        nodeDescriptor,
                        new UAMonitoringParameters(dataItem.SamplingIntervalMs,
                                               new UADataChangeFilter(dataItem.DeadBandType, dataItem.DeadBandValue, UADataChangeTrigger.StatusValue)
                                               , 100 // queue size 
                                               )
                ));
            }
 
            int[] monitoredItemHandles = easyUAClient.SubscribeMultipleMonitoredItems(easyUAMonitoredItemArguments.ToArray()); // <<<<<< problem is here
            // ....
        }

Serge
Last edit: 27 Aug 2015 06:21 by support. Reason: code formatting

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

More
26 Aug 2015 14:15 #3516 by support
We can try to reproduce it here. Can you please describe step by step how to trigger the problem?

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

More
26 Aug 2015 13:26 #3515 by sun21
Dear Support,

I have a problem when OPC server temporarily becomes unavailable.

When OPC server becomes unavailable (due to OPC service shutdown during a test or network issue),
following call does not return back if time of disconnect is longer then some value (~1m):

int[] monitoredItemHandles = easyUAClient.SubscribeMultipleMonitoredItems(easyUAMonitoredItemArguments.ToArray());

I mean that the thread waits somewhere inside the SubscribeMultipleMonitoredItems(..) procedure, never comes back even after the OPC server comes back online.

OPC server: KepserverEX v5.15
OpcLabs: v5.34.205.1

How can I debug the issue?

Serge

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

Moderators: support
Time to create page: 0.216 seconds

      

 Recommend this on Google