Initiating WCF takes too long

The WCF service takes about 5-6 seconds for the first request where all calls are made very quickly. below is the client side configuration for my WCF service.

Using the IIS host.

        WSHttpBinding binding = new WSHttpBinding();
        binding.SendTimeout = TimeSpan.FromMinutes(1);
        binding.OpenTimeout = TimeSpan.FromMinutes(1);
        binding.CloseTimeout = TimeSpan.FromMinutes(1);
        binding.ReceiveTimeout = TimeSpan.FromMinutes(1);
        binding.AllowCookies = false;
        binding.BypassProxyOnLocal = false;
        binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

        binding.MessageEncoding = WSMessageEncoding.Mtom; 

        binding.TextEncoding = System.Text.Encoding.UTF8;
        binding.UseDefaultWebProxy = true;
        binding.Name = "BasicHttpBinding_ILearningService";


        binding.Security.Mode = SecurityMode.Transport;              
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
        binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
        binding.Security.Transport.Realm = "";

Server side configuration

<services>
  <service behaviorConfiguration="LearningServiceServiceBehavior" name="LearningService">
    <host>

      <baseAddresses>
        <add baseAddress="https://xxxxx/LearningService.svc" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="ILearningSuiteService">
      <identity>
        <dns value="localhost" />
      </identity>
     </endpoint>

    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="TransportSecurity" messageEncoding="Mtom" sendTimeout="00:1:00" openTimeout="00:2:00">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="LearningServiceServiceBehavior">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" httpGetUrl="http://xxxxxxx/Metadata" httpsGetUrl="https://xxxxxxxx/Metadata" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

+3
source share
3 answers

Another problem that you can see is that when using transport security, you perform a certificate check on the client each time you create a new proxy. Is it possible for certificate verification to be expensive, say because the certificate revocation list was not available in a timely manner?

Try disabling protection and see if this behavior changes.

+4
source

, , IIS- ( , baseAddresses IIS, .svc )

, IIS, ? Windows Windows Server AppFabric

+2

At the first call, the client establishes a connection with the server, and the server performs the necessary authentication, this may take some time. And based on what I found in my project, WCF serialization can take a long time for the first time if your contract is huge. After that, serialization can be much faster.

+1
source

All Articles