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.

Losing connection to OPC UA Server using QuickOPC 2023.1

More
04 Dec 2023 13:18 #12441 by support
Hello.

At this point I cannot tell what is causing the problem, because you are actually not checking for errors. With ReadXXXX and MultipleXXXX methods, instead of putting try/catch around them, you need to check the .Exception (or .Succeeded) property in each returned result element.

See e.g.:
- opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...Write%20multiple%20values.html
- opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...iple-Element%20Operations.html

When .Exception is not null (nil), it contains the .NET exception object describing the error, so this is what I am after - the interest starts with .Message property of that exception, but more info might be needed in some cases.

Regards


Regards

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

More
04 Dec 2023 13:09 #12440 by Moien
My application runs basically with almost 1 to 2% CPU load. Almost every 15 hours, the application’s CPU load increases to 7% and the connection to the OPC UA Server will be lost. I get no exception, no error and no further information although I have try except statements everywhere. My application will be freezing for 44:30 minutes and after this period everything runs fine again.

Regards

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

More
04 Dec 2023 12:52 #12439 by support
I have asked you "What is the problem?". You have not said that you "cannot read or write". This is a new information.

Describe what you mean by that you "cannot read or write"? What actually happens, in terms of method calls to QuickOPC and their results?

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

More
04 Dec 2023 12:48 #12438 by Moien
Because without a connection I cannot read from and write to the OPC UA Server!
I am reading from the server every 500 ms and the same about writing.

Regards

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

More
04 Dec 2023 12:45 #12437 by support
Hello.

This does not answer my question. Why is not having a connection a problem?

You need to read or write values. My understanding is that it works. So why bother about connections?

Regards

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

More
04 Dec 2023 12:36 #12436 by Moien
The problem is that the connection is lost to the OPC UA Server for 44:30 minutes each time. My application does not throw any exception but I can see that there is no connection to the OPC UA Server anymore!

Regards

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

More
04 Dec 2023 12:31 #12435 by support
Hello.

I do not understand then. What is the problem?
Why do you think you need a connection?

Regards

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

More
04 Dec 2023 12:12 #12434 by Moien
Hi,

I get no exception. The only change in my code is using of QuickOPC 2023.1 instead of QuickOPC 2019.1 and registering the corresponding libraries. The application is running on Windows Server 2022 instead of Windows Server 2019. Everything else is the same.

Regards

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

More
04 Dec 2023 11:20 #12433 by support
Hello.

Please provide details about the exception(s) you get when the problem occurs (the very first one is the most important), and about the exception that you get during the time when the reconnections do not succeed.

Regards

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

More
04 Dec 2023 09:30 - 04 Dec 2023 11:16 #12430 by Moien
Dear OPCLabs Support,

I have an application programmed in Delphi 11 and I am using QuickOPC libraries to connect to the OPC UA server.
I used to use the QuickOPC version 2019.1 and my application was running properly. I upgraded the QuickOPC to the version 2023.1 and since this upgrade my application loses the connection to the OPC UA server almost every 15 hours for 44:30 minutes and then reconnects to the OPC UA server. I copied part of my application here where I use MultiRead and MultiWrite functions for further analysis:
Procedure TOPCClient.ReadAllItems;
 var
 I: Integer;
 ItemRead : Boolean;
 Name : String;
 OPCUAResult: _UAAttributeDataResult;
 OPCUAResults: OleVariant;
 J,K: Cardinal;
 
 begin
   try
     if (Connected) then begin
        if (FirstCylyle) then begin
         for J := 0 to Length(OPCServerItemArray)-1 do begin
           Name := OPCServerItemArray[J].Source + '.' + OPCServerItemArray[J].ItemName;
           ReadOPCUAArguments[J] := CoUAReadArguments.Create;
           ReadOPCUAArguments[J].ReadParameters.MaximumAge := 100;
           ReadOPCUAArguments[J].EndpointDescriptor.UrlString := Url_String;
           ReadOPCUAArguments[J].NodeDescriptor.NodeId.ExpandedText := 'nsu='+ nsu + ';s=' + S0 + '.' + Name;
         end;
         OPCUAArguments := VarArrayCreate([0, Length(OPCServerItemArray)-1], varVariant);
         for I := 0 to Length(OPCServerItemArray)-1 do begin
           OPCUAArguments[I] := ReadOPCUAArguments[I];
         end;
         FirstCylyle := False;
       end;
       // Perform the operation
       TVarData(OPCUAResults).VType := varArray or varVariant;
 
       //OPCLabs 2019.2 Version
       //TVarData(OPCUAResults).VArray := PVarArray(OPCUAClientRead.ReadMultiple(OPCUAArguments));
 
       //OPCLabs 2019.1 Version
       {TVarData(OPCUAResults).VArray := PVarArray(OPCUAClientRead.ReadMultiple(
       PSafeArray(TVarData(OPCUAArguments).VArray)));}
 
       //OPCLabs 2023.1 Version
       TVarData(OPCUAResults).VArray := PVarArray(OPCUAClientRead.ReadMultiple(OPCUAArguments));
 
       // Writing the results in Delphi internal Array
       try
         for K := VarArrayLowBound(OPCUAResults, 1) to VarArrayHighBound(OPCUAResults, 1) do
           begin
             OPCUAResult := IInterface(OPCUAResults[K]) as _UAAttributeDataResult;
             OPCServerItemArray[K].Value    := OPCUAResult.AttributeData.value;
             OPCServerItemArray[K].ItemQuality := OPCUAResult.AttributeData.StatusCode.IsGood;
             OPCServerItemArray[K].TimeStamp := OPCUAResult.AttributeData.ServerTimestampLocal;
           end;
           OPCStatus_Good := True;
       except
         on E: Exception do begin
           OPCStatus_Good := False;
           Meldung(1,'TOPCClient.ReadAllItems - Exception: writing into Delphi-Intern Array ' + E.Message);
         end;
       end;;
 
     end else begin
       Meldung(0,'TOPCClient.ReadAllItems: (Not connected to the OPC UA Server!)');
     end;
   except
     on E: Exception do begin
       Meldung(0,'TOPCClient.ReadAllItems - Exception: ' + E.Message);
     end;
   end;
 end;

Procedure TOPCClient.WriteMultipleItems_DT;
Var
  I : Integer;
  Results : OleVariant;
  ExpandedText_DT : WideString;
  WriteArguments_DT: OleVariant;
 
begin
  try
    if (connected) then begin
      if (Write_DT_Variables) then begin
        for I := 0 to WriteMultipleIdx_DT-1 do begin
          if (FirstCycleWrite_DT) then begin
            WriteValueArguments_DT[I] := CoUAWriteValueArguments.Create;
            WriteValueArguments_DT[I].EndpointDescriptor.UrlString := Url_String;
          end;
          ExpandedText_DT := 'nsu='+ nsu + ';s=' + S0 + '.' + WriteToOPCServerArray_DT[I].Source + '.' + WriteToOPCServerArray_DT[I].ItemName;
          WriteValueArguments_DT[I].NodeDescriptor.NodeId.ExpandedText := ExpandedText_DT;
          WriteValueArguments_DT[I].Value := WriteToOPCServerArray_DT[I].Value;
        end;
        FirstCycleWrite_DT := False;
        WriteArguments_DT := VarArrayCreate([0, WriteMultipleIdx_DT-1], varVariant);
        for I := 0 to WriteMultipleIdx_DT-1 do begin
          WriteArguments_DT[I] := WriteValueArguments_DT[I];
        end;
 
        try
          TVarData(Results).VType := varArray or varVariant;
 
          //OPCLabs 2019.1 Version
          {TVarData(Results).VArray := PVarArray(OPCUAClientMultiWrite_DT.WriteMultipleValues(
          PSafeArray(TVarData(WriteArguments_DT).VArray)));}
 
          //OPCLabs 2023.1 Version
          TVarData(Results).VArray := PVarArray(OPCUAClientMultiWrite_DT.WriteMultipleValues(WriteArguments_DT));
          VarClear(Results);
          VarClear(WriteArguments_DT);
          Write_DT_Variables := False;
        except
          on E: EOleException do
          begin
             Meldung(0,'EOleException in TOPCClient.WriteMultipleItems_DT: ' + E.GetBaseException.Message);
          end;
        end;
      end;
 
    end else begin
      Meldung(0,'TOPCClient.WriteMultipleItems_DT: not connected to the OPC UA Server');
    end;
  except
    on E: Exception do begin
      Meldung(0,'TOPCClient.WriteMultipleItems_DT - Exception: ' + E.Message);
    end;
  end;
end;

Can you give me some hints what could be the reason for this behavior?

Best regards
Last edit: 04 Dec 2023 11:16 by Moien.

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

Moderators: support
Time to create page: 0.064 seconds