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.

Unsubscription Error

More
13 Apr 2021 16:42 #9607 by support
Replied by support on topic Unsubscription Error
Hello,

HoldPeriod is actually both the things you mentioned. If you are doing "single-shot" things only, the session is needed just for a limited amount of time - to perform the operation requested. And the hold period starts counting at the time the operation completed. If you subscribe to something, you need to keep the session open. The counting of the hold period therefore cannot start until all subscriptions are removed.

If you want to make sure that the session is terminated before you close the program, yes - you need to 1) unsubscribe from everything, and 2) wait.

The necessary waiting time is controlled by the HoldPeriod. If you want to make it shorter you can, and also consider shortening EasyUAClient.SharedParameters.EngineParameters.GarbageCollectionPeriod (default 2000 milliseconds) - this is how often the program looks at which sessions can be closed (are after their hold period).

Regards

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

More
13 Apr 2021 14:01 #9601 by Rperez
Replied by Rperez on topic Unsubscription Error
Hello,

Thank you for all the clarifications.

Well, the time set in the Hold Period, it is because we understood the Hold Period like the time the session ends if nothing happen. But if I understand correctly, this time is the time that the session remain open when all the tags are unsubscribed, right?

Then, If we want to terminate the session we need to wait a Period of time (10 sec aprox.) before closing the program, right?

Best Regards,

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

More
13 Apr 2021 11:32 #9600 by support
Replied by support on topic Unsubscription Error
One more comment: The default HoldPeriod is 5000 (in milliseconds, i.e. 5 seconds).
I would expect you to set it to a lower value (so that the disconnection happens earlier), not a higher value (15000 as in your code).

Best regards

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

More
13 Apr 2021 06:41 #9599 by support
Replied by support on topic Unsubscription Error
Hello.

In the default state, when Isolated == false, if you have multiple EasyUAClient-s and they use the same target server, they will share the connection to it (session); this also means that parameters that relate to that connection have to be shared (static).

When you set Isolated = true, then the EasyUAClient object in this stare will not share its connection with other instances of EasyUAClient.

Normally you do not set Isolated to 'true', and unless there is a specific need, discussing it in relation with your issue only complicates things and I do not know why you have introduced it.

You are setting the HoldPeriod correctly.

The session remains open until all subscriptions on that session are unsubscribed using one of the UnsubscribeXXXX methods, or using EasyUAClient.Dispose or finalizer (but in all cases, with a delay). You may have some of it in your program, but you have not posted these parts. So, if you only had the parts you have posted, they will do the subscribe, and the session will remain open. If your program closes, quite likely the EasyUAClient finalizer will be called and the session closing "countdown" will start, but the actual program termination will occur before the session is actually closed. That is simply repeating the behavior and explanation I gave before.

Best regards

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

More
12 Apr 2021 08:12 - 12 Apr 2021 14:13 #9597 by Rperez
Replied by Rperez on topic Unsubscription Error
Hello,

Yes, the behaviour of "reload" it is fine.

Which is the difference between use isolated method or not? Is the way to communicate different or it is only to activate some functionality?

Could you tell me the parameters which influence on timing of session open?

Can you give me an example of the HoldPeriod Method?

We use the following code with Isolated = true, but the session gets open undefinitelly:
Public Sub InitOPC()
   UAClient = New EasyUAClient()
   UAClient.Isolated = True
   UAClient.IsolatedParameters.SessionParameters.HoldPeriod = 15000
   Dim itemSubscriptionArgumentsArray(ru.Tags.Count - 1) As EasyUAMonitoredItemArguments
   Dim itemCounter As Integer = 0
   For Each tag As Tag In ru.Tags
           Dim captureFrec As Integer = tag.CaptureFrec * 1000
           Dim item As New EasyUAMonitoredItemArguments(tag.Id, ru.IP, tag.OPCItem, New UAMonitoringParameters(captureFrec))
           itemSubscriptionArgumentsArray(itemCounter) = item
           itemCounter += 1
   Next
   Dim subscriptionIds() As Integer = UAClient.SubscribeMultipleMonitoredItems(itemSubscriptionArgumentsArray)
   If itemCounter > 0 Then
       For counter As Integer = 0 To ru.Tags.Count - 1
           ru.Tags(counter).OPCSubscriptionId = subscriptionIds(counter)
       Next
   End If
End Sub

We also try to do it without isolated with the same result:
Public Sub InitOPC()
   EasyUAClient.AdaptableParameters.SessionParameters.HoldPeriod = 15000
   UAClient = New EasyUAClient()
   Dim itemSubscriptionArgumentsArray(ru.Tags.Count - 1) As EasyUAMonitoredItemArguments
   Dim itemCounter As Integer = 0
   For Each tag As Tag In ru.Tags
           Dim captureFrec As Integer = tag.CaptureFrec * 1000
           Dim item As New EasyUAMonitoredItemArguments(tag.Id, ru.IP, tag.OPCItem, New UAMonitoringParameters(captureFrec))
           itemSubscriptionArgumentsArray(itemCounter) = item
           itemCounter += 1
   Next
   Dim subscriptionIds() As Integer = UAClient.SubscribeMultipleMonitoredItems(itemSubscriptionArgumentsArray)
   If itemCounter > 0 Then
       For counter As Integer = 0 To ru.Tags.Count - 1
           ru.Tags(counter).OPCSubscriptionId = subscriptionIds(counter)
       Next
   End If
End Sub 

Are we doing something wrong?

Thank you in advance for your support.

Best Regards,
Last edit: 12 Apr 2021 14:13 by support. Reason: code formatting

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

More
10 Apr 2021 09:54 #9594 by support
Replied by support on topic Unsubscription Error
Hello,
thank you for the details.

The behavior on "reload" is as designed, and I do not see any problem with it (do you?). QuickOPC keeps the session open for some time, and closes it only if it is not used afterwards. There are parameters to influence the timing of this (let me know if you want to know more).

The behavior on "end program" is also as designed, but I agree there is something that begs for improvement.

Internally, precisely the same thing is happening as above. But, if the program terminates before the session is closed, then yes, the session remains open. Again, the timing of this can be influenced (made shorter or longer), but that does not change the general principle. Unfortunately, there is currently no way for you to know precisely when all sessions were closed, which would allow you to block the program termination until then. But you with extra logic, you could use the EasyUAClient.ServerConditionChanged to get info about individual session disconnections.

The best suggestion I can give is probably to shorten the delay before the session is closed, *and* add some wait before program termination to allow for it to happen. Future versions of QuickOPC may improve on that.

The parameter to change the delay is not the SessionTimeout. It is (mainly) the HoldPeriod. Note that values under IsolatedParameters are only effective when you also set the "Isolated" property to "true". If Isolated is "false" (the default), you need to use the static EasyUAClient.AdaptableParameters.SessionParameters instead.

Best regards

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

More
09 Apr 2021 07:18 #9588 by Rperez
Replied by Rperez on topic Unsubscription Error
Hello,

First of all, thank you for your quick response.

I have to options to send that funcion:
  • Reloat: the program will continue running, if we wait those 10 seconds the sension ends and then start a new one, otherwise, if we didn't wait those 10 seconds, it gets the previous session.
  • End Program: the program ends after this function. If we wait those 10 seconds we can apreciate in the OPC Server that the session is liberated, otherwise it gets indefinitelly open

We didn't get any fail, but we can see in the OPC Server that the session is not closed. It is a problem because the OPC Server has a limited session counter.

I was asking for a SessionTimeout, in order to close the session automatically after a defined time. Is that an option?

Thank you in advance.

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

More
08 Apr 2021 18:51 #9586 by support
Replied by support on topic Unsubscription Error
Hello,
Can you please explain a bit more.

1. Does your program terminate right after the unsubscription code you posted, or does it continue running?

2. What do you mean by "the unsubscription fails"? Is it that you observe that the session remains open, or is there also some error message/exception?

3. What is the intent of your question about SessionTimeout? Is it because you believe it is related to this issue? (it is not).

Thank you.

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

More
08 Apr 2021 16:53 #9585 by Rperez
Unsubscription Error was created by Rperez
Good Morning

I am writing in order to Unsubscription in OPC Ua.

When I do the following code the unsubscriton get well:

Public Sub ClearOPC()
If UAClient IsNot Nothing Then
Try
UAClient.UnsubscribeAllMonitoredItems()
Sleep(10 * 1000)
LogTXT("[OPC UA] Waiting for tags unsubscription...")
UAClient.Dispose()
UAClient = Nothing
Catch ex As Exception
End Try
End If
End Sub


If the sleep is less than 8 seconds the unsubscriton fail and the session remain Open forever.

Do I did something wrong? Is it needed to wait 10 seconds in order to unsubscribe before the dispose function.

Is there any way to send a Session Timeout? I saw the following function for isolated mode:
UAClient.IsolatedParameters.SessionParameters.CloseTimeout
UAClient.IsolatedParameters.SessionParameters.SessionTimeout
UAClient.IsolatedParameters.SessionParameters.SessionConnectTimeout
UAClient.IsolatedParameters.SessionParameters.ShortestAllowedRevisedSessionTimeout
UAClient.IsolatedParameters.SessionParameters.HoldPeriod

But I seems I am doing something wrong because they are not working.

Thank you in advance.

Best Regards,

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

Moderators: support
Time to create page: 0.077 seconds