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.

Read service is denied for client

More
17 Jul 2023 18:14 #11918 by support
Hello.

Ok, from your further responses, I now understand that by saying "the app console creates a new client every loop", you did not mean that the application creates a new EasyUAClient object; you probably meant that a new OPC UA session is created.

That is right - if you read repeatedly with QuickOPC, and you leave enough idle time between the reads, QuickOPC will use a new session each time. But, it will also first close the existing session, except under extremely rare circumstances. So, there won't be more than one open session to the server at any given time. If, on the server side, it looks like that the number of open sessions is increasing, then there is something wrong in the server or in the client, but it is *not* the simple fact that you are reading in a loop.

The proper way to address this would be first to upgrade to newest QuickOPC, and if the problem persists, analyze the communication (using WireShark) and see if A) QuickOPC is not closing the connections (likely QuickOPC bug), or B ) the QuickOPC is closing them but not the server (= server bug).

But, if you want to do a "workaround", you can try to keep the session open all the time. And yes, in newer QuickOPC versions, you can use the IEasyUAClientConnectionControl, but not in 2018.2. In older versions, you can prolong the "hold period" so that the session does not get closed between the reads.

See opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...sionParameters~HoldPeriod.html

You need to set this property to a value that is higher than your period of reading.

Last but not least: it is not at all clear that the cause of your problem has to do with the exceeded number of sessions. One missing piece is the StatusCode, which would be good to know what is the actual error the server is reporting to the client. You should obtain it (log it). It is not true, as you wrote, that you "do not get this code", because, in fact, you have posted pieces of your program that *do* check the status. But they only check whether it is Good. But when it is not Good, you throw it away and do not make it available. And that is what needs to be fixed.

Regards

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

More
17 Jul 2023 09:34 #11915 by mpedro
Reading the documentation and the examples i have found a way to "lock the connection"

opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User's...tion%20Control%20Services.html
IEasyUAClientConnectionControl Interface

But I see in version 2018.2 (the version I run) I don't have the Interface IEasyuAClientConnetionControl to lock the connection. Could it be the reason that I'm not using this property that the application always is creating a new client?

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

More
17 Jul 2023 07:43 #11912 by mpedro
Good morning, first of all thank you for the reply.

- *Do not* repeatedly create new instances of EasyUAClient. Simply create one upfront, and use it all the time.
I create a server cilent outside the while, so I can tell you that i'm using only one instance of the object
What the loop performs in a resumed way is:
void read()
            List<PLC> llistaPLC = new List<PLC>();
 
            loadPLCInfo(llistaPLC); //load from db some info I need later
 
            var server = new EasyUAClient //declare here the server
            {
                Isolated = false,
                IsolatedParameters =
                {
                    SessionParameters =
                    {
                        EndpointSelectionTimeout = 20000,
                        SessionConnectTimeout = 20000,
                        SessionTimeout = 20000
 
 
                    }
                }
            };
 
            server.IsolatedParameters.SessionParameters.SessionTimeout = 20000;
 
            while (true) //start of the loop
            {
                for (int i = 0; i < llistaPLC.Count; i++) //i iterate every plc that is inside the list
                {
 
                    if (PingHost(llistaPLC[i].ip)) //only proceed with the reads if the plc is online
                    {
						Console.WriteLine("tipus maquina: " + (llistaPLC[i].tipusMaquina.Trim()));
						AlgorismeLecturaREGEV(llistaPLC[i], server); //read the different plc shortcuts with readMultiple
                    }
                    else
                    {
                        Console.WriteLine("UNABLE TO READ PLC.IP: " + llistaPLC[i].ip);
                    }
                }



- *Do not* set Isolated to 'true'.
I'm setting the properties to isolated false plus the following:
var server = new EasyUAClient
{
Isolated = false,
IsolatedParameters =
{
SessionParameters =
{
EndpointSelectionTimeout = 20000,
SessionConnectTimeout = 20000,
SessionTimeout = 20000
}
}
};
server.IsolatedParameters.SessionParameters.SessionTimeout = 20000;

I am still missing the actual OPC UA status code - from my previous post:
i don't get this code because in every iteration firstly I ping the PLC, if i do not get response (maybe the machine is under maintenance, i do not read)

3. If the StatusCode is not Good, your code should log it. I don't understand why it is necessary to log the status

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

More
15 Jul 2023 10:31 #11909 by support
Hello.

If you are reading repeatedly in a loop:

- *Do not* repeatedly create new instances of EasyUAClient. Simply create one upfront, and use it all the time.
- *Do not* set Isolated to 'true'.

I am still missing the actual OPC UA status code - from my previous post:

3. If the StatusCode is not Good, your code should log it.

Regards

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

More
13 Jul 2023 14:12 #11906 by mpedro
Hello,
thank you for the reply.

scenario:
FactoryTalk linx Gateway
Opclabs
C# app console -->"infinite loop" reading multiple PLC

The thing here is that the app console creates a new client every loop under the FactoryTalk server. This is a problem after every 2 weeks because the OPC server gets the maximum clients allowed and it crashes giving me bad access or user denied.

I have read the documentation on how to open and close a client agains the opc server but i do not find a way to do this operation. What I have found is to set the client isolated or no, different time outs (SessionParameters =
{
EndpointSelectionTimeout = 15000,
SessionConnectTimeout = 15000,
SessionTimeout = 15000


}
}

but this previous solution do not seem to fix the problem. Is there any way to create a server and delete it after the operation is completed? I have tried also to dispose the component but it still appears on the rockwell side...

Attachments:

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

More
23 May 2023 17:08 #11752 by support
Hello.

We generally recommend using the latest released version of our software. However, in this case, I do not see any particular to do so; it does not look like anything we have addressed. In fact, the problem is almost certainly on the server side, and you should investigate there, as I already wrote.

But, there are some aspects of your code that can - and should - be improved. Please read my suggestions below. They are NOT going to resolve the problem, but they will make your code more robust, and possibly even provide information that can be useful in investigating the problem.

1. The try/catch block around ReadMultiple call is useless and should be removed. ReadMultiple *never* throws, exception for usage (coding) errors (such as passing in a null object).

2. Instead, your code should test whether the .Exception property of each obj[0], obj[1], obj[2] is null, and if it is not, there was an error, and your code should log it.

3. If the StatusCode is not Good, your code should log it.

4. Instead of converting the StatusCode to string and testing it for being "Good", simply use its .IsGood property.

More reading:

- opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...with%20asynchronous%20or_.html

- opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...%20the%20actual%20result_.html

- opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...iple-Element%20Operations.html

- opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...me.html#OPC%20UA%20Errors.html

Best regards

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

More
23 May 2023 13:30 #11751 by mpedro
Other possible test I was thinking, could it be that the version I own is too old? 2018.2

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

More
23 May 2023 13:08 #11750 by mpedro
Hello, apologize me for my way of trying to explain the problem as English is not my native language.

I try to use all the best practices when reading and consulting the OPC. I read the items and then I check if the status.

When I say something blocks I mean some operation do not allow me to read/interact with OPC. It does not throw me any exception but it logs the "access denied" event on the event windows log.


To read i do the following:

 
 
 
UAEndpointDescriptor servidorUA = "opc.tcp://xx:1234/xyz";
 
 
UAReadArguments t1 = new UAReadArguments();
t1.EndpointDescriptor = servidorUA;
t1.NodeDescriptor = RegEVPunter_IN;
 
 
UAReadArguments t2 = new UAReadArguments();
t2.EndpointDescriptor = servidorUA;
t2.NodeDescriptor = RegEVPunter_OUT;
 
UAReadArguments t3 = new UAReadArguments();
t3.EndpointDescriptor = servidorUA;
t3.NodeDescriptor = RegEVLongPila;
 
vectorResultatLecturaUA[0] = t1;
vectorResultatLecturaUA[1] = t2;
vectorResultatLecturaUA[2] = t3;
UAAttributeDataResult[] obj = new UAAttributeDataResult[3];
 
try
            {
obj = _servidor.ReadMultiple(vectorResultatLecturaUA);//here I get access denied
            }
catch (Exception ex)
            {
Console.WriteLine("error lectura REGEV " + ex.ToString());
            }
 
            if (obj[0].AttributeData != null)
            {
Console.WriteLine("linia 206");
            if ((obj[0].AttributeData.StatusCode.ToString() == "Good"
            && obj[1].AttributeData.StatusCode.ToString() == "Good"
            && obj[2].AttributeData.StatusCode.ToString() == "Good"))
            {
            //other operations
            }
 


Inside the try-catch block, in the "//here" comment, i suspect that there I get access denied. But as it does not throw any exception is why I'm lost and don't know how to proceed in order to manage the situation.

Just to remind, I have the OPC server configured with security: none and authentication: anonymous

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

More
23 May 2023 10:01 #11749 by support
Hello.
I do not quite understand.

Please clarify:

1. What do you mean by "I check the status when I get a read, but the thing here is that i can not proceed to read due an access denied to the item." . What is the actual StatusCode in the UAAttributeData?

2. What do you mean by "Something after some time... blocks the operations read/write.". When someone says "blocks", it usually means that a method call is made but never returns. Is it what you are observing? If not, what do you mean by "block"?

Regards

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

More
23 May 2023 06:12 #11748 by mpedro
Hello, thank you.
I check the status when I get a read, but the thing here is that i can not proceed to read due an access denied to the item. Something after some time(aprox 14 days, and it's not a license grace period because I have all licenses) blocks the operations read/write. This don't allow me to check status, quality...
I have all patches installed from Rockwell and I still get the same error.

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

Moderators: support
Time to create page: 0.118 seconds