TCP WCF Service isn't executing Application_Start - wcf

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.

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?

Calling a net.tcp wcf service from Silverlight - in an external facing web site?

I have an external (public) website developed in Silverlight. The Silverlight app currently calls http based wcf services hosted in IIS.
I am now having to call a wcf service with net.tcp binding hosted in a different app server. I have the net.tcp wcf service hosted in a windows service on port range 4502-4530 and with an interface to expose clientaccesspolicy.xml file as part of the service. I am able to invoke this service from my Silverlight app in the web server. I want the SL app to make direct call to net.tcp, rather than routing the call to it from another http based service.
Question is will this work without any issues when exposed over internet.
Client browser --> IIS webserver with Silverlight website --> App Server with wcf service on net.tcp.
I am assuming in this case, from XAP SL would try to make direct call to the app server service using net.tcp ?
The communication between the web server and app server could be opened up for ports 4502-4535. But I am wondering what about the client. Does this setup require the ports to be available even in the clients machine (with browser)?
Any insight is much helpful.
Thanks.
Take a look at http://support.microsoft.com/kb/2425652; there is sample code included as well! If you setup clientaccesspolicy.xml correctly; it should work as long as clients can access your TCP server.
If your clients are behind some firewall which is blocking your server's ports; they may face connectivity issues!

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).

Questions about adding a WCF service to a Windows service assembly

I have found some basic information about hosting a WCF service in a Windows service, but not much. All of my experience thus far with WCF has been in Web projects. I have a few simple questions.
I have a project which creates a windows service application. I have done a right click -> add WCF Service. This creates Service1.cs and IService1.cs.
I'm wondering why no SVC file is created in this scenario? When I add services to Web projects i get an SVC file which I can navigate to and use to consume the service.
Adding the service adds some configurations to the app.config under the services element. I'm seeing a default base address of
http://localhost:8732/Design_Time_Addresses/WindowsServiceName.services/WCFServiceName/
What does this mean? It's sort of an odd looking address. Am I supposed to change it to whatever I want?
Navigating to this address in a browser results in an unable to connect message. Does the windows service itself have to be running to talk to the WCF service?
How do I go about consuming this service from another application without an svc file?
I'm taking a guess on this first one, but I'm thinking the .svc file when hosting in IIS is to tell IIS, "Hey I have a WCF service here, please handle accordingly".
The base address is as it should be and yes you can change it if I'm not mistaken.
You can't hit the WCF service unless the Windows service is running, which is one of the dangers of hosting in a Windows service, because if the service dies somehow your WCF service is offline until you get the Windows service running again.
You consume the service the same way you do any other WCF service, just using that base address to get at it.

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

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.