Strange response delay
- Hi all
I'm experiencing a very strange fixed response delay of 500 millis when calling a WCF Service method from a Windows Forms Application. The delay occurs only if I use wsHttpBinding and set security mode to None or if I use basicHttpBinding. If I use wsHttpBinding with the standard Message security mode, then there's no problems on my developer machine, but I can't use Message mode on my webhost, because the service should be used anonymously.
I'm using the WCF basic service example as a test to see how a very simple setup performs. So the method is just returning a string.
The really strange thing about this 500 millis delay is that it only happens when I execute the application on the developer machine(Windows Vista). If I start the same application on my laptop(Windows XP), which then calls the service located on the developer machine, then there's no delay at all. I also get a 500 millis delay in Windows 7.
So if the endpoint of the service in the application is set to http://devmachinename/Service1.svc and wsHttpBinding|SecurityMode.None or basicHttpBinding is used, then I get the follwing response times:
dev.machine calls dev.machine service = ~500 millis response time
laptop calls dev.machine service = < 10 millis response time
When using basicHttpBinding and calling my webhost instead of my dev.machine I get the exact same behavior.
dev.machine calls webhost service = ~500 millis response time
laptop calls webhost service = < 50 millis response time
While searching for a solution I came across this article: http://support.microsoft.com/default.aspx/kb/892100 and began to think about if the delay is caused by the fact that my dev.machine is a Core 2 Duo(multiprocessor) and my laptop is a single processor? Or maybe it's Vista/7 that is the problem?
For the record, I'm acually devolping a standard .NET 2.0 web service where I also get a 500 millis delay on every web service method call, and with the exact same behavior when calling the web service from my laptop -> dev.machine(no delay). So I'm really just trying to figure out what's causing this weird behavior in both cases, since they must be related. But if I find a solution to all this I think I'm switching to WCF Services as I'm liking it more than the old fashion web services.
Can anyone help?
Answers
- Thank you for trying to help Riquel, but I finally found out what the problem was...
Today I found this thread which basically describes the same problem that I was having.
Apparently the problem is NOD32 Antivirus 4, but only when installed on Windows Vista/7. Windows XP has no problem with NOD32 installed. I use NOD32 on both my machines.
To solve the problem I went to NOD32 > Advanced setup > Web access protection > HTTP, HTTPS and unchecked Enable Http Checking.
Now my web service calls are super fast again.
Thank you all for taking the time to try and help.- Marked As Answer byveccie Sunday, November 08, 2009 2:34 AM
All Replies
- Greetings,
In the you are using application in intranet environment, I would suggest you try with netTCPBinding.
Take Care
PL
Helping People To Solve Technical Problems Greetings,
In the you are using application in intranet environment, I would suggest you try with netTCPBinding.
Take Care
PL
Helping People To Solve Technical Problems
Thank for your answer.
But the intranet test was only made to see if it behaved differently, which it did. It actually performed much better, and that doesn't make sense in my opinion.
I'm also only using the dev.machine for both the client and service while developing the whole thing. The production version of this solution will be a client application calling the service located on my webhost, but I can only use http bindings because the webhost is running IIS 6.0.
As mentioned in my first post it doesn't matter if the service is located on my dev machine or my webhost and using basicHttpBinding. I get a ~500 millis in response delay in both cases, but only when the client is executed on my dev.machine. When using the laptop it all runs perfectly.- Greeting,
If you have time , one simple suggestion. Only if required. Use II 7.0 installed in windows server 2008. .Net version 3.0 and above version most suitable for in Vista and in Window 7.
As you mentioned "use http bindings because the webhost is running IIS 6.0 ".Just change the IIS 6.0 to IIS 7.0. I know that you cannot simple change things in a production envirnoment, there alot things needed to be considered when such decisions are made.
Some links is given below
Microsoft.com Operations Performance Analysis of IIS 7.0/Windows Server 2008
- http://blogs.technet.com/mscom/archive/2008/06/09/microsoft-com-operations-performance-analysis-of-iis-7-0-windows-server-2008.aspx
Top 10 Performance Improvements in IIS 7.0
- http://technet.microsoft.com/en-us/magazine/2008.09.iis.aspx?pr=blog
How to Migrate from IIS 6 to IIS 7
- http://blogs.iis.net/bills/archive/2008/06/18/how-to-migrate-from-iis-6-to-iis-7.aspx
Only trying to help.
Take Care
PL.
Helping People To Solve Technical Problems - Unfortunately my webhost is a shared environment, so it's not something I can change, unless I put up some big cash and get a dedicated host or similar. So right now I'm stuck with Windows Server 2003/IIS 6.0. If I had the chance I would change to Windows Server 2008/IIS 7.0 in an instant.
Don't get me wrong, I appreciate your effort to help, but there's something that doesn't make sense to me. In my opinion a service call from localhost to localhost should be faster than a service call over an intranet and definitely faster than over the internet to a webhost. A service call from my XP machine to the dev.machine is 100 times faster than a simple local call on the dev.machine. And 10 times faster over the internet. That isn't right. And as mentioned the exact same behavior happens when using the old regular web service from .NET 1.1/2.0, which should be running smoothly on IIS 6.0.
It seems to me that Vista/7 have some sort of issue with .NET service calls, because the same service calls works perfectly from an XP machine. I have a feeling that it might be an authentication problem in Vista/7, because when using wsHttpBinding(SecurityMode.Message) it works perfectly on the dev.machine(5ms response time). There's definitely some sort of hickup in Vista/7, since the delay is 500ms in response time every single time + the time it takes to get the actual data.
Ohwell, I hate computers :) - Hi Veccie,
I didn't reproduce your scenario. I made one simple test in my Environment.
WinXP+SP3+VS2008( hardware: Intel Pentium 4 CPU 3.0 GHz)
one console application. Output is:
47988 .NET Framework 3.5 client
Win2008+SP1+VS2008(hardware: Intel Pentium 4 CPU 2.8 GHz)
one console application. Output is:
60020 .NET Framework 3.5 client
Service code:
namespace ConsoleApplication23
{
[ServiceContract]
public interface ISimpleService
{
[OperationContract]
string SimpleMethod(string msg);
}
class SimpleService : ISimpleService
{
public string SimpleMethod(string msg)
{
Console.WriteLine("The caller passed in " + msg);
return "Hello " + msg;
}
}
class Program
{
static void Main(string[] args)
{
NetworkCredential cr = CredentialCache.DefaultNetworkCredentials;
Console.WriteLine(cr.UserName);
Console.WriteLine(cr.Password);
ServiceHost svcHost = new ServiceHost(typeof(SimpleService), new Uri("http://riquel-pc:8006/MetadataSample"));
try
{
// Check to see if the service host already has a ServiceMetadataBehavior
ServiceMetadataBehavior smb = svcHost.Description.Behaviors.Find<ServiceMetadataBehavior>();
// If not, add one
if (smb == null)
smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
svcHost.Description.Behaviors.Add(smb);
// Add MEX endpoint
svcHost.AddServiceEndpoint(
ServiceMetadataBehavior.MexContractName,
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex"
);
// Add application endpoint
svcHost.AddServiceEndpoint(typeof(ISimpleService), new WSHttpBinding(), "");
// Open the service host to accept incoming calls
svcHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
svcHost.Close();
}
catch (CommunicationException commProblem)
{
Console.WriteLine("There was a communication problem. " + commProblem.Message);
Console.Read();
}
}
}
}
Client code:
class Program
{
static void Main(string[] args)
{
Stopwatch swh = new Stopwatch();
swh.Start();
SimpleServiceClient sc = new SimpleServiceClient();
sc.Open();
for (int i = 0; i < 1500; i++)
{
if (i == 250 || i == 750 || i == 1450)
{
Console.WriteLine(sc.SimpleMethod("my test " + i.ToString()));
}
else
{
sc.SimpleMethod("my test " + i.ToString());
}
}
sc.Close();
swh.Stop();
Console.WriteLine(swh.ElapsedMilliseconds.ToString() + " .NET Framework 3.5 client");
Console.ReadLine();
}
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - Thank you for trying to help Riquel, but I finally found out what the problem was...
Today I found this thread which basically describes the same problem that I was having.
Apparently the problem is NOD32 Antivirus 4, but only when installed on Windows Vista/7. Windows XP has no problem with NOD32 installed. I use NOD32 on both my machines.
To solve the problem I went to NOD32 > Advanced setup > Web access protection > HTTP, HTTPS and unchecked Enable Http Checking.
Now my web service calls are super fast again.
Thank you all for taking the time to try and help.- Marked As Answer byveccie Sunday, November 08, 2009 2:34 AM
- Hi Veccie,
Glad to hear this solution! This is valuable for community members who face the same issues.
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.


