Professional OPC
Development Tools


Using KEPServerEx Sim Driver && Getting dropped subscriptions

27 Feb 2015 14:04 #2864 by Bmello4688
Our application is a WPF application where we utilize the MVVM design pattern. This pattern allows us to use Microsoft's test framework to automate test cases through the viewmodel layer.

The reason I cannot send you the entire code base is because of confidential reasons and because it is too large.

The reason you are seeing 2 clients running in parallel is because our automation test uses a RobotClient to flip tags that our application is waiting on in the tag database. There are always 2 clients running. One in the actual application and one to simulate our robots behavior.

The reason I want to use Isolation mode is because when our application is finished I want to explicitly dispose/close the client without affecting any other clients that are running. I always manually cleanup the client which is why I do not need any internal logic that determines if the session or subscriptions need to be dropped. A typical test case will run for about 30 - 45 seconds with continuous communication between the client and server (max of 2000ms wait). Another reason I would prefer to keep Isolated on because I do not want my real client and test client sharing sessions and subscriptions. I want them to communicate with the server independently and just allow the tag DB be the object the relays information from test client to real client.

A lot of my settings on the client are probably unnecessary. They are just there as failed attempts to keep the session open indefinitely and to keep all subscriptions alive until I unsubscribe and close the session.

I will try to send you a performance test project that reproduces the problem so you can run it and see what is happening. You should have everything you need on the server. The only thing I failed to mention was we have disabled all security on the endpoint we are using.

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

27 Feb 2015 08:02 #2861 by support
Thank you very much.
I have received the email with the data as well.
There is a plenty of new information, and a plenty to reply to – all comes below.

Comments and observations

1. According to the communication on this forum, I was expecting the code (which I partially have now), and the server configuration (which I do not have yet?). I did not know you were going to make the Wireshark capture right away and start resolving with Kepware. We could have changed the code first (“Things to do” further below).

2. Indeed the communication does not look how it should. But is too early to conclude where the problem originates. Under normal circumstances the things observed do not take place: only one connection is used, and when subscribed, it stays open. Therefore there must be something somewhere which causes the different behavior in your case. It could be the component (us), or your code, or (less likely) the server.

3. Not only there are sessions not being closed, but from the very beginning there see, to be two connections being made in parallel. We need to establish why. I think this is related to the Isolated setting – this is covered further below in the Questions.

4. The subscription with sampling interval 15000 ms and publishing interval 7500 ms is an internal subscription to monitor the state of the server. Kepware has not noticed that there is a second subscription being created right after that, which is the one that holds your monitored items and has their parameters.

5. It appears that the first “real” failure seen in Wireshark (ServiceFault, frame #5810, approx. 82.885 seconds from start) corresponds to the first “publishing stopped” in your app log (2015-02-23 22:23:25,317). The communication, however, is far from normal from the very beginning – this moment is just when the problems become apparent.


6. What kind of project is your application? E.g. console app, Windows Forms app, Windows Service, Web service, Web app, or something else?

7. Please describe the lifetime cycle of the RobotClient object. If possible, send a code that creates/calls/destroys them. Are you creating just one, or more – how many? When/for what purpose are they created? How long do they typically live? Are you explicitly calling Dispose() on them? Please explain this as thoroughly as possible, it is important.

Things to do

8. Do not set EasyUAClient.Isolated to ‘true’, unless you have a solid reason for it (if you this is the case, please explain and discuss it here before we go any further). With Isolated = true, if multiple RobotClient objects are instantiated, each one will end up with its separate connection to the server. Set Isolated back to ‘false’. Note that consequently, the parameters that you are currently setting under IsolatedParameters will need to be set in the static property EasyUAClient.AdaptableParameters instead, just once, at the beginning of the program.

9. You set RetrialDelay on a session and on a subscription to 200 milliseconds (and ServerShutdownRetrialDelay to 1000). These are extremely small values that are not going to help anything. In fact, they only make matters worse, because they complicate the diagnostics and troubleshooting, and can create unnecessary extra load on the system. Refrain from changing the defaults, or make them at least several seconds long.

These I think do not relate to the problem at hand, but are worth noting anyway.

10. Upgrade to version 5.32, free of charge (download from our Web site). Besides some bug fixes (but none to this particular problem, as far as I am aware), there are improvements in diagnostics (things being logged).

11. Do not use the handles returned from SubscribeXXXX to identify your subscribed items (in a dictionary). Please read the user manual (Concepts), section Best Practices – there is a whole chapter about it.

12. For efficiency, if you can, do call methods like SubscribeMonitoredItem, Read etc. sequentially. Prepare the arguments upfront and then call SubscribeMultipleMonitoredItems, ReadMultiple etc. More about it – in the Best Practices section again.

13. Your code combines the hooking of instance events (MonitoredItemChanged) in the same place with the static event (LogEntry). If more of your instances are created, this would mean that the event handler for LogEntry would be called multiple times, and it logs to the same storage, there will be duplicate entries.

Other notes

14. It seems that you can control which event types (from our LogEntry) go into your app log. The app log you have sent seem to only have the errors. If we get to do something like this again, please capture the warnings and infos as well.

15. It’s a pity that I do not have a self-contained code that I can run, reproduce the issue and work on it here. Do you think you would be able to modify the app so that it can be sent over in full? (it does not have to contain the app logic, it just has to be able to show the problem).

16. Alternatively, if you give me the data such as item names etc. . (or even without them, as a kind of template), I can put together an app that just subscribes, reads, etc. as it should, verify that it works here and behaves correctly on the communication level, and then send it over to you to see whether shows the problem on your side – and if it does not, we would look into how is your own app different from this baseline.

Best regards

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

26 Feb 2015 15:45 #2859 by Bmello4688
I have been talking to KEP Server and this is what they said

What I see in the wireshark is that your client connects. it adds a subscription with a publish rate of 7500 msec. It then adds monitored items with a sampling rate of 15000msec This says that you are going to request the server to provide data every 7500 msec but you are telling it to poll the monitored items every 15000 msec.

You are connected for just about 7.5 seconds and you delete the subscription. But you do not delete the connection to the server. You then create another connection. This is why you see those messages in the server event log.

All in all this is not optimize for performance. You should connect and stay connection do not cancel the subscription. In OPC UA you can create a subscription with publishing disabled. You then just read and write as needed. The other option is to complete the process and disconnect from the server before connecting again.The server will only allow valid sessions in the version that you are using. In v5.16 we increased that to 128. It will remove the invalid or stale sessions when the currently active session is renewed. If you disconnect the server connection it will also get removed.

When looking at the easyUAClient I cannot find a default setting of 7500 msecs anywhere. When creating a subscription we use the default of 0 for publishing interval. The only other option with a default of 15000msecs is the StatusSubscriptionSamplingInterval option under Session.

What I am trying to do is create a connection to the server. Add subscriptions to the server. Use the session and subscription for an unlimited amount of time, and then unsubscribe and close the session.

How do I do this with the easyUAClient? I will forward you the package i sent to KEP.

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

05 Feb 2015 17:23 #2724 by support
Unless the information is confidential or extremely large, the best way would be to post it as an attachment right here (not all file extensions are permitted, ZIP it if you get into problems). See the Attachments/Add File controls right below the edit box where you are typing the new text.

If you cannot do this, please email to sales09 (at)

Thank you

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

05 Feb 2015 17:13 #2723 by Bmello4688
Sure I'll send you some code and the server config. Do you have an email address I can send it to?

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

05 Feb 2015 16:40 #2721 by support
I see. Thank you.

Is there a way I can reproduce it on our side? Can you send me the KEPserver configuration, plus an indication of the KEPserver version your are using, and your code, or relevant pieces of it?

Best regards

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

05 Feb 2015 14:46 #2719 by Bmello4688
When ever a receive the previously stated error in the log entry handler, I always receive an exception on the monitor item changed event of

The OPC-UA subscription publishing has stopped.

The change of the sampling rate to 1000ms did not change or fix the problem.

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

05 Feb 2015 06:01 #2709 by support
Please always state whether you actually observed a problem in your program - i.e. in this case, whether you have received an error in the notification handler. Has it been the case, when changed the sampling rate to 1000 ms, or not?

Log entries alone are not necessarily a problem.

If you received the error in the notification handler, can you please then post the full event log?

Thank you, and best regards

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

04 Feb 2015 22:34 #2708 by Bmello4688
Changing the sampling interval to 1000 had no effect.

Same exception:

The OPC-UA server on endpoint URL "opc.tcp://localhost:49320" has reported a subscription acknowledgement error with code 0x807A0000 for subscription Id 106 and sequence number 1. Further subscription acknowledgement errors with this code on this session will not be logged.
Operation result: BadSequenceNumberUnknown.

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

04 Feb 2015 20:55 #2707 by support
As far as I can tell, you have been specifying a sampling interval of 50 milliseconds. It's got to be somewhere in your code. Yes please, change it to 1000 milliseconds and observe the result.

Subscription IDs are assigned by the server. About the only requirement on them is that they must be unique inside a (client-server) session. The fact that they continuously increase does not imply that they are not getting cleaned up; it is one of the reasonable ways to implement the server.

The sequence numbers, on the other hand, must start with 1 and increase by 1, that is dictated by the OPC UA spec (in fact it is much more complicated, as the actual order in which they are received may differ, and there are acknowledgements/republish mechanism etc.).

Best regards

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

Moderators: support
Time to create page: 0.215 seconds


 Recommend this on Google