I'm trying to migrate a .NEt Remoting app to WCF, right now both services(Remoting and WCF) are living together.
I have one client consuming both of this services at the same time and I noticed that in the very first call to WCF service it takes a little bit longer than the first call to .NET Remoting service.
With .NET Remoting service the first call get response almost immediately.
.NEt Remoting first call response time: less than a second.
WCF first call response time: about 2 seconds.
I know that there is some initialization cost for WCF connection to be opened, but how can I accelerate this WCF channel wakeup time ??
Any hint?
WCF is doing so much more than remoting. There is a cost for this work. Full stop.
Try calling the WCF service before you need it. Consider adding a Heartbeat() or Init() method to the service to trigger the startup process. If the startup is completed by the first call, there should not be a delay for subsequent calls.
If you have the option to host in AppFabric then you could use the Auto-Start Feature which is specifically designed to get the application initialized before the first client call.
Benefits of the Auto-Start Feature
When you enable the auto-start
feature for a service, the service is up and running as soon as the
application that it belongs to is started and before the service
receives the first WCF message from the client. Therefore, the service
processes the first message quickly because it is already initialized.
Related
I have a case where I have to send calls to other service methods from a service method. e.g. I call a service method A.Call1() from my smart client application, then after some operations it sends call to B.Call2() and then Call2 method sends call to C.Call3().
When I send few concurrent hits to A.Call1() then all service methods stuck in IIS most of times and times out, anyone suggest a fix or better design.
I'm using simple HttpBinding, 4.6 .Net Framework with IIS 8.5 and using default throttling settings.
I have several services running. I can call everyone from a client application. I am trying to call into one service from another service (same application - they are hosted in an application for testing but can also run as a windows service).
The call I use to do this from the client is simply create the factory and CreateChannel and then open.
When I do this in a service trying to connect to another service I don't get an error it just hangs and eventually times out. I have no idea what is wrong.
I am using net.pipe://localhost/test as my endpoint and transport.
This was really stupid but (and) I will post the issue to help others that may run into this...
All of my service was running single threaded so when I called into another service it was blocking itself. I now start my threads on backgroundworker threads and the issue is gone.
Thanks
I have a WCF service that uses various config parameters that are located in a database, as well as a cache for better performance. Right now I have a Singleton that holds this information and is initialized on the first call to the Webservice in a lazy loading behavior.
The cache was exenteded lately and so the initialization takes some time, of course resulting in a longer response time on the first service request.
So what would be the most efficient way to do some kind of eager loading initialization of the service before the fist call occurs (probably on application pool start)?
Don't host the service in an asp.net application, but use a self-hosting process (i.e. a console application) or (even better) a WAS (Windows Activation Service) service within IIS.
This is much more reliable and you can initialize service BEFORE first clien call.
See MSDN for details.
I have a WCF service hosted in IIS and it is consumed by an ASP.NET application. Service and client are on diferent servers and communicate over internet.
Message security over wsHttpBinding is used as the security model (using X.509 certificate).
I tested the service with Fiddler and everything seems OK unless for a single call there are 4 sessions in fiddler (two round-trips). I don't need sessions with WCF and want my calling threads (which are asp.net worker threads), not to be blocked when calling a WCF method.
How can I achieve fire-and-forget pattern when using a WCF service (I can change the service contract if needed) ?
Fire and forget (One-Way operation) only says that your operation doesn't return any result and so client doesn't have to wait for server processing. But it has nothing to do with infrastracture calls you see in fiddler. First of all turn off estabilishSecurityContext and negotiateServiceCredentials in your security element (these are turned on by default) and try it again.
I assume that when you say "fire-and-forget" you are referring to a web service call that yields no return parameters. WCF has the notion of One-Way Method invocation that might help you here.
I've created a WCF service application containing a client, contract and a service. I use the client to call methods implemented in the service.
Is there a way to have a timer in the service and to set its interval to tick and to have a method that is executing during the time the service is being called.
I tried to create a constructor to the service (static and non-static) but it didn't work.
I thought about creating a 3rd party client, which will execute a method implemented in the service which will do what I need.
Thanks,
Oded.
If you want something running while the service is called, then you could do it from the client:
Call start process from the client
Call the service from the client
Call stop process from the client
You could also do it on the server side:
Your first line in the service is start process
Your last line in the service is stop process
Note you must be carefull about error handling, otherwise you will end up with many orphaned processes.