WCF Service in .NET 4.0 goes "to sleep" but ping wakes it back up - wcf

Good Morning, everyone.
I am somewhat new to WCF and we have created a new WCF service. This service uses net.msmq bindings to transfer and receive messages from another WCF service. This all works GREAT. However, when we deploy the service to our servers, this new WCF service "falls asleep". I'll explain.
I completely understand that the WCF Service doesn't run like a Windows service. What I mean is that, once we ping the service, it'll run fine for a few minutes. It monitors the MSMQ queues that it's supposed to and processes the messages just like it should. Send and receive work just fine. If there is a lull in the incoming data, the service just seems to stop listening. It will stay in this state until we ping the service by going to the URL exposed by the HTTP service that we had to put in place.
We didn't build this to be a RESTful service, so I wouldn't expect that to be the issue. Anyone have any ideas?
Thanks,
Jim Evans, MCAD

If the service runs under IIS it is subject to recycle timeout if there are no http requests to it. Its not clear how is the monitoring of the other service done, but without external request the IIS will put service to sleep, so perhaps change the monitored service so that it sends a notification to monitoring service.
If you have selfhosted WCF service, then please discard first paragraph, selfhosted WCF service is not affected by IIS and shouldnt go to sleep unless you turn it off.

Related

SIlverligh Client WCF routing performance

I am experiencing a strange issue in my browser hosted silverlight application. Call are made to a WCF routing service hosted in on IIS 7. The routing service then switches the protocol to nettcp and routes the request to another WCF service on our application server. This second service is hosted in a windows service. What I am noticing is that when a client on one machine invokes a long running request other users on the network cannot even get smaller requests serviced till the long running request returns. Has anyone experienced this or does anyone know what can be causing this?

Restart a WCF Service on IIS via Silverlight

Is there a built-in method to restart a WCF service that I can invoke from my client? I have a static constructor and also it would help me while I'm testing my application.
No. That would be a serious security vulnerability, if someone could somehow restart your service from a non-administrator account (a SL client just sends the request to the service over HTTP, or a non-authenticated TCP socket in SL4).
You should be able to restart the service by recycling the application pool for the application. Touching web.config should do the trick (open the file in notepad, save it, even without any modifications).

How to find out the address of multiple clients connected to a WCF duplex service?

I am currently developing a WCF duplex Service for 2 clients. The first client would be an asp.net webpage which upon receiving a posting, it will send the data over to the service. When the service receives the data, it will then AUTOMATICALLY send it to the second client which is a winform app through the callback channel...
To make it simpler.
Asp.net will invoke the wcf
The wcf will reside on the iis server, same as the asp.net
WCF will require to send a data to the windows form application that is running on a client side. Only 1 instance of this application will be run at a time.
Your service should know nothing about the clients attached to it. Doing so pretty much breaks the intention of WCF.
A better solution might be to have your clients subscribe to "events" that your service can fire off. Or maybe the client can provide some information in their requests that indicates a service and method to call back to when needed.

TCP WCF Service isn't executing Application_Start

Problem:
The Application_Start event is not being triggered in my WCF Service which contains a TCP endpoint.
Background:
I'm hitting trying to hit the service from a console app. If the service is not yet started, the call will fail because Application_Start never fires. However, if I explicitly start the service (hit the hosting web app from a browser) then and then call the service from the console app it works fine.
Question:
What gives? If the only thing being hosted in the service application is a tcp endpoint does Appliction_Start of the HttpApplication never get triggered? It makes sense to a certain degree as it is essentially being treated as a non-http application via WAS. However, it doesn't make sense because it is being hosted in IIS.
Application_Start will never be hit in a WAS hosted WCF service. This event is ASP.NET specific (no IIS specific), so unless you are hosting your WCF service in ASP.NET it won't be hit: and you are not as it is hosted by WAS.

WCF Service - automated or timed action

We have a WCF service, hosted on IIS7.5, that has to fetch some data from an external web service.
Is there some way to schedule this action to be started, in our WCF service, on a regular (timed) basis?
Thanks
Yes, create a Windows service which wakes up every x minutes or hours and makes the call.
The WCF service is not "always on" - it is typically only created when a request comes in and needs to be handled. But you would typically host your WCF service in either IIS, or self-host - which usually already means a Windows Service anyway.
I would recommend VisualCron which can schedule WCF and web service calls (amont other things).
With that tool you can supply dynamic parameters, retrieve output and parse it. If you want you can forward the data to a file, email etc.