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.

can't connect unless Opc Test Client is run

More
27 Nov 2021 19:06 #10402 by support
Hello,
thank you for letting us know.

Best regards

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

More
26 Nov 2021 19:58 #10401 by observer
To follow up: I am still having this problem (intermittent failure to connect), but it is somewhat mitigated by killing and re-starting the OPC Server (Automationworx OPC Server from Phoenix Contact) each time before I start my application. This usually (~95% of the time) solves the issue, though at the expense of a few extra seconds starting up. I have to do this in a powershell script, because trying to start up the OPC server from my C# application resulted in problems. I've been running like this (re-starting the OPC server before starting my application) for several months now. The application does not always connect even after a server re-start, but trying it again almost always works. So the worst effects of this issue have been worked around. Not completely satisfying, but usable.

Thanks for everyone's help here!

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

More
11 Aug 2021 06:35 #10105 by support
Thanks for update.

I would not hesitate increasing the hold periods significantly more. There is almost no harm making them very long, in your case. Something like

client.HoldPeriods.TopicRead = 60000;
client.HoldPeriods.TopicWrite = 60000;
I will get back to #3 if issues persist.

Best regards
The following user(s) said Thank You: observer

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

More
10 Aug 2021 21:14 #10104 by observer
Thank you so much for your help.

I increased the OPC timeouts and hold periods,
        client.Timeouts.WriteItem =12000; // ms, was 2500
        client.Timeouts.ReadItem = 12000; // was 2500
        client.HoldPeriods.TopicRead = 200; // was 100
        client.HoldPeriods.TopicWrite = 200; // was 100
And I am currently not able to reproduce the issue, but I want to wait a while before declaring victory, since the issue was intermittent.

The OPC server is Automationworx OPC Server (from Phoenix Contact) and seems to start when first used. So I may be able to pre-start it. I'm not sure how I can do #3 ("Consider adding a subscription to some item ... keeping the server always connected," because not connecting is the issue.

Thanks again for all your help on this!

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

More
30 Jul 2021 17:41 #10079 by support
Hello.
All your replies considered together, I think this points to the following possibility:

The problem is not really that you "can't connect". The connection, as such, is working fine. The problem is that you do not get the data from the server that you need.

The server may need relatively long time (much longer than normally) to provide the real, valid data when it is just started, or when the connection to it has just been made.
QuickOPC controls the connections and disconnections from the server as needed. I.e. if you just do some Read, it connects, does the Read, and then it stays connected for some time ("hold period"), and then it disconnects - *unless* the connection is needed for some other operation at that time.

This would explain why having another client helps.

The problem might be either with with any new connection to the server (even if the server has already been started), or just when the the server starting from ground up (when *no* client was connected before).

Things to do:
1. Increase the timeouts.
2. Increase the "hold periods"
3. Consider adding a subscription to some item in the server (can even be anon-existent item) that last for the whole duration of your program, keeping the server always connected. (and, add some delay after making the subscription, if that is acceptable).
4. Consult the serer documentation to check whether it can be pre-started. Some servers are started with the first client connected ("Local Server", COM/DCOM does that), but some can run e.g. as a Windows Service, in which case they can start with the system.

Best regards

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

More
30 Jul 2021 16:29 #10078 by observer

support wrote: Thank you very much. Some additional questions:
7. Do you have any try/catch(OpcException) around the ReadItemValue call?

I do have that, and catch the exception.

support wrote: 8. Is it ever invoked/does it ever get there?
9. Is the exception handler written in such a way that the exception cannot be confused with reading of value 0?
Best regards

Stepping through with the debugger, I do see it catches the exception.

The exception I see (when it fails) is:
"Topic not updated with quality that is not bad (timeout)."

This looks like: www.opclabs.com/forum/com-connections/1848-topic-not-updated...uality-that-is-not-bad-timeout

So I will now try to to use ReadItem instead of ReadItemValue and see what additional information that gives me.

Thank you for your help!

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

More
30 Jul 2021 05:10 #10075 by support
Thank you very much. Some additional questions:

7. Do you have any try/catch(OpcException) around the ReadItemValue call?

8. Is it ever invoked/does it ever get there?

9. Is the exception handler written in such a way that the exception cannot be confused with reading of value 0?

Best regards

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

More
29 Jul 2021 19:30 #10072 by observer

support wrote: Hello.
I have some additional questions.
1. Please confirm that we are dealing with OPC DA "Classic" (COM/DCOM based), and not OPC UA.

Not sure how to check this. In my C# programs I am using OpcLabs.EasyOpc.DataAccess

support wrote: 2. The OpcClient.exe - where does it come from? E.g. MAtrikonOPC?

The OPC Test Client is supplied by Phoenix Contact.

support wrote: 3. Do you just "read" the values, or do you also use subscriptions?

I am using subscriptions.

support wrote: 4. Which API method do you use for the reading? E.g. Readitem, ReadItemValue, ReadMultipleItems, ReadMultipleItemValues, and so on?

ReadItemValue

support wrote: 5. Can you post here the piece of code that does the read, and shows how the result is processed? I want to check how handling of errors and "bad" qualities is done.

object retVal = client.ReadItemValue(COMPUTER_NAME, SERVER_NAME, item_id); // the read

As for the results there, I will need to run that in the debugger to see what I get.

support wrote: 6. What do you man when you write "OPC doesn't connect." - my understanding is that, because you are not getting any errors, that by saying "OPC doesn't connect." you simply mean that you get the zero values that should not be there - but no other symptoms?
Thank you

At the application level, yes, that is what I see.

I was hoping that someone would recognize similar symptoms (often need to use OPC Test Client first, to make application correctly connect to OPC).

It will take some time to tease it apart into a simple, stand alone diagnostic program.

Thanks for your help.

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

More
29 Jul 2021 17:56 #10071 by support
Hello.
I have some additional questions.

1. Please confirm that we are dealing with OPC DA "Classic" (COM/DCOM based), and not OPC UA.

2. The OpcClient.exe - where does it come from? E.g. MAtrikonOPC?

3. Do you just "read" the values, or do you also use subscriptions?

4. Which API method do you use for the reading? E.g. Readitem, ReadItemValue, ReadMultipleItems, ReadMultipleItemValues, and so on?

5. Can you post here the piece of code that does the read, and shows how the result is processed? I want to check how handling of errors and "bad" qualities is done.

6. What do you man when you write "OPC doesn't connect." - my understanding is that, because you are not getting any errors, that by saying "OPC doesn't connect." you simply mean that you get the zero values that should not be there - but no other symptoms?

Thank you

Thank you

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

More
29 Jul 2021 17:09 #10070 by observer
I'm having an OPC application startup problem and I am unsure how to correct it. I'm using Quick OPC 5.2 in a C# application.

Sometimes (very often!) my OPC application needs to be restarted if OPC doesn't connect. (It re-tries multiple times internally, now.) And often after restarting, it won't connect either.

The way it fails is weird, also. It seems to connect, but when I try to read back values they are all 0. My connection sequence tests the connection by trying to read back a an OPC value that should not be 0.

Odd remedy:

Connecting with the OPC Test Client (OpcClient.exe) will somehow fix the connection. That is, if I leave the OPC Test Client connected, and THEN start my application (R5_Control.exe), it usually works - i.e., my application connects to OPC.

Has anyone seen anything like this before? I can make my application connect to OPC, but it is flaky. OpcClient.exe somehow makes it possible for my application to use OPC. Neither the error code (from attempting to read a value) nor an OPC event log shows anything obviously wrong.

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

Moderators: support
Time to create page: 0.060 seconds