Slow web service (and WCF service) calls from Windows 7 - wcf

I am building a .NET 3.5 Winforms app that uses WCF services (wsHttp binding) to communicate to my server which gets data from SQL Server and passes it back to the Winforms app (Smart Client). I noticed since running Windows 7 RTM there is about a 30 second delay the first time the WCF communicates, from that point forward it's normal as before.
I noticed another application (Desaware licensing system) that uses ASMX services also experiences this same problem, a startup delay then all is fine.
This first time startup is not a .NET complilation/JIT issue, I can close the app right away and do it again. The server is running Windows 2003/IIS 6. All was fine prior to Windows 7.
I tried removing my anti-virus software, same issue. I cannot figure out why there is this initial delay, a significant one at that. I notice too in the Debug window as the application is starting up a delay as the System.IdentityModel line, it looks as if there is a security/authentication change on Windows 7 I presume that is causing this delay.
Anyone have any suggestions on how to resolve this issue? VS 2008 / .NET 3.5.
Thank you.

I added the following entry into the binding configuration and it appears to have solved the issue.
useDefaultWebProxy="false"

I was experiencing the same problem. I create my proxy using a ChannelFactory object, and found that in addition to specifying useDefaultWebProxy for the binding server-side, it was also necessary to specify the option client-side:
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement
{
MaxBufferPoolSize = int.MaxValue,
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
AuthenticationScheme = System.Net.AuthenticationSchemes.Ntlm,
UseDefaultWebProxy = false
}
I found that the issue only occured when using the current Windows credentials. If you pass specific credentials then the performance was as expected. However, setting the UseDefaultWebProxy client side fixed the problem.
Hope this helps someone, somewhere!

A 30 second delay, sounds like it is waiting for something and then timing out after 30 seconds.
It is probably something to do with the authentication between your windows 7 machine and the server. Checking the event log would be a good place to start.

This worked for my Windows 7 and connecting to a WebServer
useDefaultWebProxy="false"
Thank You
Douglas

Related

IIS shutsdown website even though timeout for app pool is set to 0

Title pretty much says it all. I have created a simple ASP.NET core 3.1 website which runs a MQTT subscriper. My problem is that after a while I see message in event viewer:
Application 'MACHINE/WEBROOT/APPHOST/MYWEBSITE' has shutdown.
Is there something I should add in the website itself or in IIS to make the website always running?
I found a complete step to step guide how to fix this from:
https://www.taithienbo.com/how-to-auto-start-and-keep-an-asp-net-core-web-application-and-keep-it-running-on-iis/
The missing part from my config was to add application initialization to server roles.
I had same problem before and solved with set Rapid-Fail protection to false.
If you trust to your server performance
or increase failure and maximum failures count.

Topshelf Windows Service times out Error 7000 7009

I have a windows service programmed in vb.NET, using Topshelf as Service Host.
Once in a while the service doesn't start. On the event log, the SCM writes errors 7000 and 7009 (service did not respond in a timely fashion). I know this is a common issue, but I (think) I have tried everything with no result.
The service only relies in WMI, and has no time-consuming operations.
I read this question (Error 1053: the service did not respond to the start or control request in a timely fashion), but none of the answers worked for me.
I Tried:
Set topshelf's start timeout.
Request additional time in the first line of "OnStart" method.
Set a periodic timer wich request additional time to the SCM.
Remove TopShelf and make the service with the Visual Studio Service Template.
Move the initialization code and "OnStart" code to a new thread to return inmediately.
Build in RELEASE mode.
Set GeneratePublisherEvidence = false in the app.config file (per application).
Unchecked "Check for publisher’s certificate revocation" in the internet settings (per machine).
Deleted all Alternate Streams (in case some dll was marked as web and blocked).
Removed any "Debug code"
Increased Window's general service timeout to 120000ms.
Also:
The service doesn't try to communicate with the user's desktop in any way.
The UAC is disabled.
The Service Runs on LOCAL SYSTEM ACCOUNT.
I believe that the code of the service itself is not the problem because:
It has been on production for over two years.
Usually the service starts fine.
There is no exception logged in the Event Log.
The "On Error" options for the service dosn't get called (since the service doesn't actually fails, just doesn't respond to the SCM)
I've commented out almost everything on it, pursuing this error! ;-)
Any help is welcome since i'm completely out of ideas, and i've been strugling with this for over 15 days...
For me the 7009 error was produced by my NET core app because I was using this construct:
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
and appsettings.json file obviously couldn't be found in C:\WINDOWS\system32.. anyway, changing it to Path.Combine(AppContext.BaseDirectory, "appsettings.json") solved the issue.
More general help - for Topshelf you can add custom exception handling where I finally found some meaningfull error info, unlike event viewer:
HostFactory.Run(x => {
...
x.OnException(e =>
{
using (var fs = new StreamWriter(#"C:\log.txt"))
{
fs.WriteLine(e.ToString());
}
});
});
I've hit the 7000 and 7009 issue, which fails straight away (even though the error message says A timeout was reached (30000 milliseconds)) because of misconfiguration between TopShelf and what the service gets installed as.
The bottom line - what you pass in HostConfigurator.SetServiceName(name) needs to match exactly the SERVICE_NAME of the Windows service which gets installed.
If they don't match it'll fail straight away and you get the two event log messages.
I had this start happening to a service after Windows Creator's Edition update installed. Basically it made the whole computer slower, which is what I think triggered the problem. Even one of the Windows services had a timeout issue.
What I learned online is that the constructor for the service needs to be fast, but OnStart has more leeway with the SCM. My service had a C# wrapper and it included an InitializeComponent() that was called in the constructor. I moved that call to OnStart and the problem went away.

Delay invoking method in WCF web service - the first time

I have a WCF Web Service Framework 4 that exposes a very simple method for authentication in BasicHttpBinding
Nothing special:
[ServiceContract]
public interface IAutorizedUser
{
[OperationContract
GetAuthentication bool (string UserName, string Password
}
The problem is that when I call that method from a remote pc, before the response I have a delay of 20 seconds, the first time. The cause is not the code inside the method: even if I comment completely that code, I have the same delay. From the second time then, the method is invoked normally and quickly.
Other html pages hosted in that server are quick.
If the call of the method starts from the server hosting the web service, there's no problem. With other remote pcs in our office lan, the problem always occurs, with the only exception of another server, where the delay is limited to 5 seconds.
I realize that the terms of the problem are very generics, but instinctively I think that the issue may reside in some WCF settings. What do you think? Could you help me?
Thank you in advance,
Pileggi
The problem is useDefaultWebProxy in the client web.config, I had to set it to false:
<basicHttpBinding>
<binding name="pippo" ... useDefaultWebProxy="false">
...
Now my problems are here:
Visual Studio "Add Service Reference" - not gets all service settings
and here:
Set useDefaultWebProxy=false on WCF Client with the Web-References
Pileggi

WCF wsdualhttpbinding strange behaviour at client side that has no clear (Exception details)

to make long story as short as possible, I made a duplex WCF service, using wsdualhttpbinding, tested it on my local machine using Visual Stuido and using IIS7, thigs are working fine (i had to use windows authentication on IIS7 to make it work thu). Any way, I published the duplex service on my company network (LAN network, windows domain, IIS 6) which i used to for many WCF services (basic and ws http bindings and worked fine) and the problem is I can not get the service to work, I tried all possible configurations to the app.config and to the web.config files, still i can not make it work.. The problem is when the client start calling the duplex service It hangs and no error message or whatsoever, and after few minutes it gives me a timeout error.. there is no error at server side ( i have checked the even viewer). There is not error about port 80 or access privileges. Is there anything i am missing? anything i should take care of and i forgot? i have been awake for 20 hours trying to find a solution because i have a time line to follow or my boss will Dispose() Me..
i have tried the following:
1- I set the IsOneWay = true..
2- I run the program as admin.
3- I i set the base address to another port.. same result..
4- I used windows auth, none... same result..
5- i have tried another machine to test the client.. same result.. it hangs with no reponse.
6- I also tried running the client on windows vista, 7 and xp... same result..
7- I have played with all kind of configurations in config files and i made sure its the same on both files (app.config and web.config)..
8- I have added a static constructor in the service side to see if the service was ever reached by the client, i added few lines to add a value in the db.. and nothing was written to db.. so it was never reached..
9- Yes, when i access the service SVC page i see the page and it worked fine.. I could access the metadata as well..
10- restarting the server, restarting IIS server, Recycling AppPool...etc..
I tried all of that and many other solutions and tricks.. same result when the app is on IIS.. the strange thing is, there is no error at server side.. and i only get TimeOut error (if i get it).. While If i tried the service on the IIS installed locally it works fine.. change the config file to point to the company IIS server,,, no luck!
Is there anything i am missing??? could be something simple but i just missed it..

ChannelFactory.CreateChannel and proxy instantiation is slow in WCF

I have a client-server application, in which the client communicates with the server using WCF (WCF is used both in the client and the server).
My problem is, that instantiating the auto-generated proxy in the client, in the following way:
new Service1Client() takes constantly 15.xxx seconds.
I tried to solve this problem, and came to the following results:
1) Compiling and running the same code on other computers, ends up in the same way (always 15.xxx seconds).
2) Instantiating the proxy using ChannelFactory.CreateChannel< IService1 >()
doesn't help (it gives the same result).
My guess, is that whenever the channel factory creates a channel, it tries to do something with a 15 seconds timeout, and when it fails, it continues with creation.
By the way, I use .Net 3.5 without SP1, and cannot upgrade to SP1 :(
Thanks ahead
Even though it is already outdated, it may be useful for somebody else searching for the same. Problem could be with DNS resolution problem, that might be solved in SP1. So you can check if it happens only when you use host name or also with specified IP address.
I've seen this before, where the time was being taken in looking for a proxy server. Check your WinINET (Internet Explorer) proxy settings.
My specific reason for thinking "proxy server" is that it takes 15s. 15s sounds like a nice round number for a network timeout.
Even though this is very old information I just found this issue too although I was experiencing a 7second delay on the First call to a method on the Service Client, I tracked it (in my environment) to Internet Explorer settings as stated above, but in my circumstances it wasn't a Proxy enabled, but the Automatically Detect Settings.
Connections -> Lan Settings and Automatically Detect settings was enabled.
I played with the machine.config and app.config and set
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
Which also made no difference.
I found this answer here and thought I'd contribute a little more information in case someone else in the future experiences something like this.
(This with a .Net 4 WCF service)