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.

BadSecureChannelClosed

More
12 Mar 2018 16:53 #6139 by support
Replied by support on topic BadSecureChannelClosed
Thank you very much. Let's focus on the hang in ReadMultipleValues which really appears to be the main issue.

This can be a deadlock - can you please obtain the call stacks with one of the methods described here?: kb.opclabs.com/Obtaining_.NET_call_stacks_in_a_COM_application (I think you already did that earlier). Notice the "minidump" method which appears to be faster and usually works well too.

Best regards

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

More
12 Mar 2018 15:28 #6138 by RVersteeg
Replied by RVersteeg on topic BadSecureChannelClosed
Hello !

1. 2018.1 (5.52.91.1)

2. The main probelm is that the thread hangs by ReadMultipleValues !

3. From ReadMultipleValues

4. My application runs now over 1 hour. The ReadMultipleValues never come back !

5. I have started a secon instance ! This work well !

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

More
12 Mar 2018 15:10 #6137 by support
Replied by support on topic BadSecureChannelClosed
Hello,

I also need to know the following:

1. Which version and build of QuickOPC you are using.

2. In the duplicate posting you made, you mention the fact that ReadMultipleValues blocks. If it blocks, it cannot return an error. Are we then discussing two issues here? - one that the function does not return, and the other that you get the error that does not recover? Please clarify.

3. When you do get the BadSecureChannelClosed, is that from ReadMultipleValues, or is it reported through the data change notification (or both?)

4. For complete analysis, can you please wait a bit more than 10 minutes on ReadMultipleValues to see whether it truly does not return even after this long time. The reason for it is that one of the timeouts involved (OperationTimeout) defaults to 10 minutes.

5. Very important: When you get into the situation where the application does not recover, start a second instance of the same application, and try to connect. Do you also get an error, or does the second instance work well?

Thank you

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

More
12 Mar 2018 15:04 #6136 by RVersteeg
Replied by RVersteeg on topic BadSecureChannelClosed
Hello

The same !

I have made two runs !

Here my Delphi XE Pas file

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

More
12 Mar 2018 15:01 #6135 by support
Replied by support on topic BadSecureChannelClosed
Hello,

what is the purpose of Trace.csv versus Trace.csv - do they show somehow different issues, or basicxally thw same thing from two independent runs?

Regards

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

More
12 Mar 2018 14:57 #6134 by RVersteeg
Replied by RVersteeg on topic BadSecureChannelClosed
Hello !

I have a small Application with tow Threads !

One Thread read a weight value :


procedure TOPCThreadReader.Read;
VAR
Arguments: OleVariant;
Results: OleVariant;
WriteResult: _ValueResult;
res: string;
i: integer;
Value : Variant;
begin
ReadArguments.EndpointDescriptor.UrlString :=
'opc.tcp://920-11-01-003:4840';

changer := false;
ReadArguments.NodeDescriptor.NodeId.ExpandedText :=
'ns=4;s=MAIN.Modul1_Gewicht';
Position_Read:=1;
Arguments := VarArrayCreate([0, 0], varVariant);
Arguments[0] := ReadArguments;

Position_Read:=2;
TVarData(Results).VType := vararray or varVariant;
Position_Read:=3;
TVarData(Results).VArray :=
PVarArray(Client.readmultiplevalues(PSafeArray(TVarData(Arguments)
.VArray)));
Position_Read:=4;

for i := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
begin
WriteResult := IInterface(Results) as _ValueResult;
if WriteResult.Succeeded then
begin
Value:=WriteResult.value;
Rueckgabe:=formatfloat('0.000',value);
Position_Read:=5;
end
else
begin
res := ReadArguments.NodeDescriptor.NodeId.ExpandedText + ':' +
WriteResult.Exception.GetBaseException.Message;
Rueckgabe:=res;
Position_Read:=6;
end;
end;

Varclear(Arguments);
// CoUAWriteValueArguments(WriteValueArguments1).Free;
end;



The Second Thread has a monitored Item with the same Item !


procedure TOPCThreadChange.subscribe;
var
i: integer;
Arguments: OleVariant;
HandleArray: OleVariant;
MonitoredItemArguments: array of _EasyUAMonitoredItemArguments;
laenge: integer;
Position: integer;
begin
try
laenge:=1;
MonitoringParameters := CoUAMonitoringParameters.Create;

MonitoringParameters.SamplingInterval := 100;
setlength(MonitoredItemArguments, laenge);

for i := 0 to laenge - 1 do
begin
MonitoredItemArguments := CoEasyUAMonitoredItemArguments.Create;
MonitoredItemArguments.EndpointDescriptor.UrlString :=
'opc.tcp://920-11-01-003:4840';
MonitoredItemArguments.NodeDescriptor.NodeId.ExpandedText :=
'ns=4;s=MAIN.Modul1_Gewicht';
MonitoredItemArguments.MonitoringParameters := MonitoringParameters;
end;

Arguments := VarArrayCreate([0, laenge - 1], varVariant);
for i := 0 to laenge - 1 do
begin
Arguments := MonitoredItemArguments;
end;
TVarData(HandleArray).VType := vararray or varVariant;
TVarData(HandleArray).VArray :=
PVarArray(Client.SubscribeMultipleMonitoredItems
(PSafeArray(TVarData(Arguments).VArray)));
except

end;

end;


The application connect to a TwinCAT 3 OPC UA Server over network !

Now i Disconnect and Connect the netwok cable !

1. Disconnect network cable !
2. Wait until Error Message appears !
3. Connect Network Cable !
4. Wait until weight value appears !

This i retry 5 - 10 times

Sometimes i got an Error "BadsecureChannelClosed" This Error never go awway. The Thread hangs in this line

TVarData(Results).VArray :=
PVarArray(Client.readmultiplevalues(PSafeArray(TVarData(Arguments)
.VArray)));

I have trces the scenario !!
Attachments:

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

More
12 Mar 2018 14:41 - 12 Mar 2018 14:57 #6133 by RVersteeg
Hello !

I have a simple application with two threads !

One Thread read a Value Weight from a TWINCAT 3 OPC Server !

procedure TOPCThreadReader.Read;
VAR
  Arguments: OleVariant;
  Results: OleVariant;
  WriteResult: _ValueResult;
  res: string;
  i: integer;
  Value : Variant;
begin
  ReadArguments.EndpointDescriptor.UrlString :=
    'opc.tcp://920-11-01-003:4840';
 
    changer := false;
    ReadArguments.NodeDescriptor.NodeId.ExpandedText :=
      'ns=4;s=MAIN.Modul1_Gewicht';
  Position_Read:=1;
  Arguments := VarArrayCreate([0, 0], varVariant);
  Arguments[0] := ReadArguments;
 
  Position_Read:=2;
  TVarData(Results).VType := vararray or varVariant;
  Position_Read:=3;
  TVarData(Results).VArray :=
    PVarArray(Client.readmultiplevalues(PSafeArray(TVarData(Arguments)
    .VArray)));
  Position_Read:=4;
 
  for i := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do
  begin
    WriteResult := IInterface(Results[i]) as _ValueResult;
    if WriteResult.Succeeded then
    begin
      Value:=WriteResult.value;
      Rueckgabe:=formatfloat('0.000',value);
      Position_Read:=5;
    end
    else
    begin
      res := ReadArguments.NodeDescriptor.NodeId.ExpandedText + ':' +
        WriteResult.Exception.GetBaseException.Message;
     Rueckgabe:=res;
     Position_Read:=6;
    end;
  end;
 
  Varclear(Arguments);
end;

The Second Thread "TOPCThreadChange" has a Client with one Monitored Item Weight
procedure TOPCThreadChange.subscribe;
var
  i: integer;
  Arguments: OleVariant;
  // Handle: Cardinal;
  HandleArray: OleVariant;
  MonitoredItemArguments: array of _EasyUAMonitoredItemArguments;
  laenge: integer;
  Position: integer;
begin
  try
    laenge:=1;
    MonitoringParameters := CoUAMonitoringParameters.Create;
 
    MonitoringParameters.SamplingInterval := 100;
    setlength(MonitoredItemArguments, laenge);
 
    for i := 0 to laenge - 1 do
    begin
      MonitoredItemArguments[i] := CoEasyUAMonitoredItemArguments.Create;
      MonitoredItemArguments[i].EndpointDescriptor.UrlString :=
         'opc.tcp://920-11-01-003:4840';
      MonitoredItemArguments[i].NodeDescriptor.NodeId.ExpandedText :=
        'ns=4;s=MAIN.Modul1_Gewicht';
      MonitoredItemArguments[i].MonitoringParameters := MonitoringParameters;
    end;
 
    Arguments := VarArrayCreate([0, laenge - 1], varVariant);
    for i := 0 to laenge - 1 do
    begin
      Arguments[i] := MonitoredItemArguments[i];
    end;
    TVarData(HandleArray).VType := vararray or varVariant;
    TVarData(HandleArray).VArray :=
      PVarArray(Client.SubscribeMultipleMonitoredItems
      (PSafeArray(TVarData(Arguments).VArray)));
 
  except
 
  end;
 
end;

The Application connect over Network to the TWINCAT 3 OPC UA Server !

1. Now I Disconnect the network cable.
2. Wait Until a Error Message Appears.
3. Connect Network cable.
4. Wait Until Weight Value Appears. O.K.

After 5 to 10 retrys i got an Error . EBadSecureChannelClosed !

The Client never connect again to the OPC UA Server !

I have a Trace the scenario !
Attachments:
Last edit: 12 Mar 2018 14:57 by support.

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

Moderators: support
Time to create page: 0.217 seconds