OPCFoundation / UA-.NETStandard-Samples

Other
263 stars 187 forks source link

Exception when UA COM Server Wrapper is under much load #60

Closed bjaben closed 3 years ago

bjaben commented 5 years ago

In a project we're seeing the below exception when using the UA COM Server Wrapper. We're running against a Cimplicity 8.1 and 8.2 OPC DA Servers. We have the UA COM Server Wrapper set up on the same machine as Cimplicity (running Window 7). We can sample nodes through the Wrapper using UAExpert but when we sample nodes through the Wrapper using the OPC Publisher from Microsoft the following exception is thrown repeatedly by the UA COM Server Wrapper: Id: Bad Description: Cannot access a disposed object. Object name: 'The COM server has been disposed.'. Cannot access a disposed object. Object name: 'The COM server has been disposed.' --- at Opc.Ua.Com.Client.ComObject.BeginComCall[T](String methodName, Boolean throwOnError) in C:\Users\User\source\repos\UA-.NETStandard\ComIOP\Common\Client\ComObject.cs:line 171 --- at Opc.Ua.Com.Client.ComDaClient.ReadPropertyValues(String itemId, Int32[] propertyIds) in C:\Users\User\source\repos\UA-.NETStandard\ComIOP\Common\Client\Da\ComDaClient.cs:line 843

This happens even if we're just sampling one node every 2 seconds.

Here are the reproduction steps:

Opc.Ua.ComServerWrapper.Config.xml:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationConfiguration
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ua="http://opcfoundation.org/UA/2008/02/Types.xsd"
  xmlns="http://opcfoundation.org/UA/SDK/Configuration.xsd">
  <ApplicationName>UA COM Server Wrapper</ApplicationName>
  <ApplicationUri>urn:localhost:UA:ComServerWrapper</ApplicationUri>
  <ProductUri>http://opcfoundation.org/UA/ComServerWrapper</ProductUri>
  <ApplicationType>Server_0</ApplicationType>

  <SecurityConfiguration>

    <!-- Where the application instance certificate is stored (MachineDefault) -->
    <ApplicationCertificate>
      <StoreType>Directory</StoreType>
      <StorePath>%CommonApplicationData%\OPC Foundation\pki\own</StorePath>
      <SubjectName>CN=UA COM Server Wrapper, C=US, S=Arizona, O=OPC Foundation, DC=localhost</SubjectName>
    </ApplicationCertificate>

    <!-- Where the issuer certificate are stored (certificate authorities) -->
    <TrustedIssuerCertificates>
      <StoreType>Directory</StoreType>
      <StorePath>%CommonApplicationData%\OPC Foundation\pki\issuer</StorePath>
    </TrustedIssuerCertificates>

    <!-- Where the trust list is stored (UA Applications) -->
    <TrustedPeerCertificates>
      <StoreType>Directory</StoreType>
      <StorePath>%CommonApplicationData%\OPC Foundation\pki\trusted</StorePath>
    </TrustedPeerCertificates>

    <!-- The directory used to store invalid certficates for later review by the administrator. -->
    <RejectedCertificateStore>
      <StoreType>Directory</StoreType>
      <StorePath>%CommonApplicationData%\OPC Foundation\pki\rejected</StorePath>
    </RejectedCertificateStore>

    <AutoAcceptUntrustedCertificates>false</AutoAcceptUntrustedCertificates>

  </SecurityConfiguration>

  <TransportConfigurations />
  <TransportQuotas>
    <OperationTimeout>600000</OperationTimeout>
    <MaxStringLength>1048576</MaxStringLength>
    <MaxByteStringLength>4194304</MaxByteStringLength>
    <MaxArrayLength>65535</MaxArrayLength>
    <MaxMessageSize>4194304</MaxMessageSize>
    <MaxBufferSize>65535</MaxBufferSize>
    <ChannelLifetime>300000</ChannelLifetime>
    <SecurityTokenLifetime>3600000</SecurityTokenLifetime>
  </TransportQuotas>
  <ServerConfiguration>
    <BaseAddresses>
      <ua:String>opc.tcp://localhost:48400/UA/ComServerWrapper</ua:String>
    </BaseAddresses>
    <SecurityPolicies>
      <ServerSecurityPolicy>
        <SecurityMode>SignAndEncrypt_3</SecurityMode>
        <SecurityPolicyUri>http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256</SecurityPolicyUri>
      </ServerSecurityPolicy>
    </SecurityPolicies>
    <MinRequestThreadCount>5</MinRequestThreadCount>
    <MaxRequestThreadCount>100</MaxRequestThreadCount>
    <MaxQueuedRequestCount>2000</MaxQueuedRequestCount>

    <!-- The SDK expects the server to support the same set of user tokens for every endpoint. -->
    <UserTokenPolicies>
      <!-- Allows anonymous users -->
      <ua:UserTokenPolicy>
        <ua:TokenType>Anonymous_0</ua:TokenType>
        <ua:SecurityPolicyUri>http://opcfoundation.org/UA/SecurityPolicy#None</ua:SecurityPolicyUri>
      </ua:UserTokenPolicy>
      <!-- Allows user certificates -->
      <ua:UserTokenPolicy>
        <ua:TokenType>Certificate_2</ua:TokenType>
        <!-- certificate possession must be proven with a digital signature - this specifies what algorithm to use -->
        <ua:SecurityPolicyUri>http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256</ua:SecurityPolicyUri>
      </ua:UserTokenPolicy>
    </UserTokenPolicies>

    <DiagnosticsEnabled>true</DiagnosticsEnabled>
    <MaxSessionCount>100</MaxSessionCount>
    <MinSessionTimeout>10000</MinSessionTimeout>
    <MaxSessionTimeout>3600000</MaxSessionTimeout>
    <MaxBrowseContinuationPoints>10</MaxBrowseContinuationPoints>
    <MaxQueryContinuationPoints>10</MaxQueryContinuationPoints>
    <MaxHistoryContinuationPoints>100</MaxHistoryContinuationPoints>
    <MaxRequestAge>600000</MaxRequestAge>
    <MinPublishingInterval>100</MinPublishingInterval>
    <MaxPublishingInterval>3600000</MaxPublishingInterval>
    <PublishingResolution>50</PublishingResolution>
    <MaxSubscriptionLifetime>3600000</MaxSubscriptionLifetime>
    <MaxMessageQueueSize>100</MaxMessageQueueSize>
    <MaxNotificationQueueSize>100</MaxNotificationQueueSize>
    <MaxNotificationsPerPublish>1000</MaxNotificationsPerPublish>
    <MinMetadataSamplingInterval>1000</MinMetadataSamplingInterval>
    <AvailableSamplingRates />

    <RegistrationEndpoint>
      <ua:EndpointUrl>opc.tcp://localhost:4840</ua:EndpointUrl>
      <ua:Server>
        <ua:ApplicationUri>opc.tcp://localhost:4840</ua:ApplicationUri>
        <ua:ApplicationType>DiscoveryServer_3</ua:ApplicationType>
        <ua:DiscoveryUrls>
          <ua:String>opc.tcp://localhost:4840</ua:String>
        </ua:DiscoveryUrls>
      </ua:Server>
      <ua:SecurityMode>SignAndEncrypt_3</ua:SecurityMode>
      <ua:SecurityPolicyUri />
      <ua:UserIdentityTokens />
    </RegistrationEndpoint>

    <MaxRegistrationInterval>0</MaxRegistrationInterval>
    <NodeManagerSaveFile>Opc.Ua.Server.nodes.xml</NodeManagerSaveFile>
    <MinSubscriptionLifetime>10000</MinSubscriptionLifetime>
    <MaxPublishRequestCount>20</MaxPublishRequestCount>
    <MaxSubscriptionCount>100</MaxSubscriptionCount>
    <MaxEventQueueSize>10000</MaxEventQueueSize>
  </ServerConfiguration>
  <Extensions>
    <ua:XmlElement>
      <ComWrapperServerConfiguration xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://opcfoundation.org/UA/SDK/COMInterop">
        <WrappedServers>
          <ComClientConfiguration i:type="ComDaClientConfiguration">
            <ServerUrl>opc.com://localhost/CIMPLICITY.HMI.OPCServer.1</ServerUrl>
            <ServerName>DA</ServerName>
            <MaxReconnectWait>10000</MaxReconnectWait>
            <SeperatorChars></SeperatorChars>
            <AvailableLocales>
              <ua:String>en-US</ua:String>
              <ua:String>de-DE</ua:String>
              <ua:String>ja-JP</ua:String>
            </AvailableLocales>
            <BrowseToNotSupported>false</BrowseToNotSupported>
          </ComClientConfiguration>
        </WrappedServers>
      </ComWrapperServerConfiguration>
    </ua:XmlElement>
  </Extensions>

  <TraceConfiguration>
    <OutputFilePath>%CommonApplicationData%\OPC Foundation\Logs\Opc.Ua.ComServerWrapper.log.txt</OutputFilePath>
    <DeleteOnLoad>true</DeleteOnLoad>
    <!-- Show Only Errors -->
    <!-- <TraceMasks>1</TraceMasks> -->
    <!-- Show Only Security and Errors -->
    <!-- <TraceMasks>513</TraceMasks> -->
    <!-- Show Only Security, Errors and Trace -->
    <!-- <TraceMasks>515</TraceMasks> -->
    <!-- Show Only Security, COM Calls, Errors and Trace -->
    <TraceMasks>1023</TraceMasks>
    <!-- Show Only Security, Service Calls, Errors and Trace -->
    <!-- <TraceMasks>523</TraceMasks> -->
    <!-- Show Only Security, ServiceResultExceptions, Errors and Trace -->
    <!-- <TraceMasks>519</TraceMasks> -->
  </TraceConfiguration>

</ApplicationConfiguration>

publishednodes.json:

[
  {
    "EndpointUrl": "opc.tcp://CIMPL:48400/UA/ComServerWrapper",
    "OpcNodes": [
      {
        "Id": "ns=2;s=0:\\\\TESTPROJ\\TESTOBJ.PV.VALUE",
        "OpcSamplingInterval": 2000,
        "OpcPublishingInterval": 5000,
        "HeartbeatInterval": 3600,
        "SkipFirst": true
      }
    ]
  }
]

Any idea what could be happening here?

petrovickn commented 4 years ago

Is there any news on this issue? We are facing the same problem in our project.

ezequielfalcon commented 4 years ago

This is old, but something similar is happening to me. We're using the Wrapper with a GE iFIX OPC DA server. If we use a standard OCP UA Client (like Integration Objects one) it works flawlessly, but I soon as I try to get a NodeID variable with node-opcua library it throws this same error.

omarine commented 4 years ago

Hello,

we start to have a lot of issues as soon as we start to acquire like 130k signals,i was trying to debug but i have no idea how ths Wrapper exposes opcua methods.

we have timeout when our client (opcpublisher) istrying to setmonitoreditem (1000 monitored nodes )

the issue as well is there is no documentation about how this Wrapper works !

if anyone could help i'd appreciate.

tukotech commented 3 years ago

I am using the wrapper to get 30K from DeltaV OPC Server subscribing at 1000ms.

tukotech commented 3 years ago

@bjaben @AlinMoldovean - I am wondering if this issue should be marked closed for now due to inactivity.

Note that I have used the wrapper subscribing to 30K and the parameter were changing every second.

EdnerPontes commented 3 years ago

Hello,

I know that is issue is closed, but I need some help with something like this (maybe I will put another issue). Basically I can use the wrapper with few items, but when I tried to load more than 500 items, the client just trace timeout's messages. I can´t monitore the items in ths case... Am I missing something basic? Please if someone could help i'd appreciate ...

tukotech commented 3 years ago

@EdnerPontes, can you please check if the server is able to handle 500 items? I would start with CPU usage of the server.

By the way, what OPC classic server are you wrapping?

EdnerPontes commented 3 years ago

@tukotech thank you for your comment ! We are using (wrapping) our DA Server - (2.05a classic and CTT Compliant) and its normal the usage of thousands items. We tested against others OPC UA Clients with the same behaviour. We still tested with some simulation DA Server (Matrikon, Integration

tukotech commented 3 years ago

@EdnerPontes - how does the item path looks like for your OPC DA server?

For example, DeltaV OPC server looks like this: MODULE1/FB/PARAM.CV

The reason I am asking is that path separator should be configured on the wrapper correctly otherwise it will have to traverse the address space to look for the item. So for the above example, path separator is /

See link below for a fork I did and how it was configured: https://github.com/wickedtuko/COMtoUA/blob/deb57685b11bdb8c74a0ca22846f4903556951a5/ComIOP/Wrapper/ServerWrapper/Opc.Ua.ComServerWrapper.Config.xml#L152

EdnerPontes commented 3 years ago

@tukotech it was a really good tip ! Once again thank you !

Our tag separator is "." (dot) so our tag looks like: Block.Parameter.Element

Now I changed the xml to: "... <"SeperatorChars">.<"/SeperatorChars"> ..."

Now I´ll do some tests to observe the performance and if we can reach more than is expected...

EdnerPontes commented 3 years ago

@tukotech once again thank you for your time and for have answered my question...

"The reason I am asking is that path separator should be configured on the wrapper correctly otherwise it will have to traverse the address space to look for the item. So for the above example, path separator is /"

Our tag separator is dot "." ....I follow your instruction and changed the xml ... this maked the difference and now everything is working fine !

Best Regards !