0

I have a web site that communicates with a .NET 4 WCF web services. That WCF service connects to Dynamics GP Web Services on a remote server. Both Web Services are self-hosted (no IIS).

The first call to GP takes around 12 seconds to complete!! Calls immediately after (even in another WCF request) are around 100ms, but if I wait a minute or two between calls, it will take again 10 seconds...

What could be the cause of the issue, how can I resolve it?

I've generated a proxy using both SvcUtil and VS 2010 Add Service Reference, but got the same problem with both. The Dynamics GP proxy file is huge 3MB, don't know if that's related.

I ran Wireshark to analyse network traffic and the actual tcp request-reply stream seems to take less than a second. There seems to be something going on before the request is sent that take up that 10 seconds.

Here is the code used:

Context context = new Context();
CompanyKey companyKey = new CompanyKey();
companyKey.Id = -1;
context.OrganizationKey = companyKey;

System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();

_proxy = new DynamicsGPClient();
_proxy.ClientCredentials.Windows.ClientCredential.Domain = Domain;
_proxy.ClientCredentials.Windows.ClientCredential.UserName = Username;
_proxy.ClientCredentials.Windows.ClientCredential.Password = Password;

long openingMs = sw.ElapsedMilliseconds;
CustomerCriteria customerCriteria = new CustomerCriteria();
CustomerSummary[] gpCustomers = _proxy.GetCustomerList(customerCriteria, context);
long fctCallMs = sw.ElapsedMilliseconds;
...
if (_proxy != null && _proxy.State != System.ServiceModel.CommunicationState.Faulted) {
    _proxy.Close();
}

Here's the app.config:

<system.serviceModel>
   <bindings>
      <wsHttpBinding>
         <binding name="GPWebService" closeTimeout="00:01:00" openTimeout="00:01:00"
                  receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" 
                  transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
                  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
                  messageEncoding="Text" textEncoding="utf-8" 
                  useDefaultWebProxy="true" allowCookies="false">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
                          maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/>
            <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
            <security mode="Message">
               <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
               <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
            </security>
         </binding>
      </wsHttpBinding>
   </bindings>
   <client>
      <endpoint address="http://192.168.x.y:48620/Dynamics/GPService/GPService" binding="wsHttpBinding"
                bindingConfiguration="GPWebService"
                contract="DynamicsGpService.DynamicsGP" name="GPWebService">
         <identity>
            <userPrincipalName value="DEV\gpeconnect"/>
         </identity>
      </endpoint>
   </client>
</system.serviceModel>
dstj
  • 4,800
  • 2
  • 39
  • 61
  • I don't know anything about Dynamics, but this sounds to me like the IIS app pool that is hosting the Dynamics services is being started for the first time. This can take some time. Assuming this is the case, you may want to check the timeout setting on the app pool. The default timeout for IIS app pools is 20 minutes, so increasing that should decrease the number of times you have to go through this startup delay. – chris.house.00 Nov 19 '11 at 00:29
  • Thanks Chris, but I wouldn't think so, both Web Services (Dynamics' and my own) are "self-hosted". And, it's well below the 20 minutes mark that the long delay comes back... – dstj Nov 19 '11 at 16:43

1 Answers1

2

Self answer

For the community, here's what I have found out (but I can't explain why, so don't ask! ;))

In the Client's app.config, useDefaultWebProxy="true" should be set to false... this made a very simple Hello World Web Service pass from 7 sec to ~100ms on the first call.

In the Client's app.config, completely removing the identity > userPrincipalName section caused the first WCF call to pass from > 10 sec to ~1 sec!

dstj
  • 4,800
  • 2
  • 39
  • 61