WCF host 15 seconds delay

I use .NET 3.5 and WCF to develop a server-client application. Binding = BasicHttp. I work and deploy a service on a Windows 2003 sp2 server.

The service on the server is self-serviced by the console application, and everything works fine on my computer. The fact is that when you deploy the server to the computer, it must start, it must EXACTLY 15 seconds to open the serviceHost instance, when it should be milliseconds. I could live with it, but also, when this instance receives the first request from the client, it takes EXACTLY 15 seconds to respond, and, like this, with each new client. After the first request, it only takes a few milliseconds to answer the following questions.

I do not have this problem on my computer and I have tried many others and it works great. I have no way to format the server on which I am deploying, so I need advice on what might be wrong with this particular computer or configuration. This behavior is repeated using ANY service that I want to host on this computer, even in the basic example in the WCF service template, so for simplicity I am working on this while I am solving this problem. This is the app.config that I use in the main application. The rest of the code is exactly the one above. Please keep in mind that the service is working properly, this is a delay that makes the work unusable.

Thanks in advance!

<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <compilation debug="true" /> </system.web> <!-- When deploying the service library project, the content of the config file must be added to the host app.config file. System.Configuration does not support config files for libraries. --> <system.serviceModel> <services> <service name="WcfServiceLibrary7.Service1" behaviorConfiguration="WcfServiceLibrary7.Service1Behavior"> <host> <baseAddresses> <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary7/Service1/" /> </baseAddresses> </host> <!-- Service Endpoints --> <!-- Unless fully qualified, address is relative to base address supplied above --> <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary7.IService1"> <!-- Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs. If removed, WCF will infer an appropriate identity automatically. --> <identity> <dns value="localhost"/> </identity> </endpoint> <!-- Metadata Endpoints --> <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="WcfServiceLibrary7.Service1Behavior"> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="True"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="False" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration> 

App.config Client:

 <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <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://localhost:8732/Design_Time_Addresses/WcfServiceLibrary7/Service1/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1" name="WSHttpBinding_IService1"> <identity> <dns value="localhost" /> </identity> </endpoint> </client> </system.serviceModel> </configuration> 
+4
source share
4 answers

The problem was resolved when I found out that .NET 3.5 Service Pack 1 was not installed. I had problems on the computer. As soon as I installed it, it all started fine, without delay.

Thanks everyone for the advice! Regards Nacho

0
source

Downloading ServiceHost for the first time always takes a lot of time. Some reasons:

  • Download assemblies
  • Port Opening
  • JITting Code
  • Perform various reflection operations

So, if your car is not very good, it can be even longer. I do not think that there is anything related to how you do it.


UPDATE

After looking at the client configuration, it turns out that the security used as a message with clientCredentialType="Windows" will call the domain controller, which is probably disconnected .

+2
source

I would start by using a client-side violinist to find out what is happening. If necessary, you can also do netmon if there are problems with a network interface other than http.

On the server side, you can project, trace, or log in to find out how many times during this 15-second request, time was spent on the server code.

At least they will tell you where to start.

If for each client a new request, you should look at authentication, DNS name resolution and other network configurations. Another good experiment will be after this 15-second request for the user, utilization of the server application and re-request. 15 seconds again? If not, this is probably the network; if so, then in the / config application.

+2
source

Guess - and that's nothing more - is that the DNS timeout somewhere resolves some kind of network name. Does

ping localhost

also gives you a delay of fifteen seconds?

Similarly, it is possible that something is trying to do a reverse DNS lookup for the incoming host name. Do your remote hosts have names resolved by the server?

You can also check if there is a firewall or virus scanner that intercepts HTTP requests in some strange way when you open a connection on port 8732.

+1
source

Source: https://habr.com/ru/post/1381109/


All Articles