Click here to Skip to main content
15,887,946 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a simple WCF service using a tcp binding that was working great until I added certificate security. Once I did that I began to see about a 45 second delay before the service received the message and processed it. Using WireShark it appears that there is security negotiation of some sort going on and then the service stops responding for about 45 seconds and finally it responds to the client and the data comes across. I removed the security and once again it works in near real time. Does anyone have any experience with something like this?

Here's the service config:

XML
<services>
  <service behaviorConfiguration="MEXGET" name="AtcSystemService.AtcSystemService">
    <endpoint binding="netTcpBinding" bindingConfiguration="TcpBindingConfig" name="tcpEndpoint" contract="AtcSystemService.IAtcSystemService"/>
    <endpoint kind="udpDiscoveryEndpoint"/>
    <endpoint address="net.tcp://CONW-W7-PHILLP:58009" binding="netTcpBinding" bindingConfiguration="TcpLargeFileBinding" name="tcpLargeFileEndpoint" contract="AtcSystemService.IAtcStreamService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://CONW-W7-PHILLP:58008"/>
        <add baseAddress="http://CONW-W7-PHILLP:8888"/>
      </baseAddresses>
    </host>
  </service>
</services>
<bindings>
  <netTcpBinding>
    <binding name="TcpBindingConfig">
      <security mode="Message">
        <message clientCredentialType="Certificate"/>
      </security>
    </binding>
    <binding name="TcpLargeFileBinding" maxReceivedMessageSize="1048576" transferMode="Streamed">
      <security mode="Transport">
        <transport clientCredentialType="Certificate"/>
      </security>
    </binding>
  </netTcpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="MEXGET">
      <serviceDiscovery/>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceCredentials>
        <serviceCertificate findValue="CN=AtcCert" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName"/>
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>


And here is the client side code.

C#
mBinding = new NetTcpBinding();
mBinding.Security.Mode = SecurityMode.Message;
mBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
mIdentity = new DnsEndpointIdentity("AtcCert");


C#
IAtcSystemService GetServiceProxy()
{
    var myAddress = new EndpointAddress(mServiceAddress.Uri, mIdentity,    
                                        mServiceAddress.Headers,
                                        mServiceAddress.GetReaderAtMetadata(),
                                        mServiceAddress.GetReaderAtExtensions());
    var factory = new ChannelFactory<IAtcSystemService>(mBinding, myAddress);
    factory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser,           
                 StoreName.My, X509FindType.FindBySubjectDistinguishedName,          
                 "CN=AtcCert");
    factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode 
                 = X509CertificateValidationMode.ChainTrust;
    return factory.CreateChannel();
}
Posted

1 solution

Since SSL need a series of handshakes between the servers, it might take a while to reach to the actual method call. One issue could be an overhead encryption. This is only for the first time call. However once they acknowledge each other, it will not have significant delay to access the method. Perhaps this article explains about the issue clearly.Web Services Over SSL - Is It Really That Slow Like They Say?[^]. Here is another good point on performance between http vs https[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900