views:

308

answers:

2

I'm trying to get IIS6 to work reliably with a WCF service I have hosted in a separate Windows Service application on the same machine. Users connect to IIS via some HTTP exposed services, which is working fine, and then IIS needs to get some information from the Windows service to put in the HTTP response. I also need a callback channel between the Windows Service and IIS.

After a lot of effort I got it working with a netTcpBinding and everything would be rosey for 5 or 10 minutes but after that IIS would report the WCF channel as being faulted and then clam up and stop processing any requests until the worker process got recycled and the whole thing repeated.

I've been trying to swap to a netNamedPipeBinding but IIS refuses or is refused access to the pipe with an "There was no endpoint listening at net.pipe://localhost/mypipename" error. I can connect to the pipe fine from a console app.

So my question is has anyone got either of those two bindings working with IIS as a client or have any other approaches?

A: 

Can you show me the code you use to dispose of the wcf client proxy?

Never use 'using' on a wcf proxy, as it will not dispose correctly every time. This can possibly lead to the faulted state.

Michel van Engelen
That one does seem to have caught a lot of people out :). It's not the problem in my case but I am tweaking my fault handling to see if I can improve it starting with trying to narrow down exactly they appear all of a sudden.
sipwiz
+1  A: 

We are using IIS 7 hosting about 20 services with the net.tcp and net.pipe bindings and it's working fine.

Your problem with the pipe looks like a misconfiguration to me. If it helps, this is how we have them configured:

Server:

 <endpoint address ="" binding="fooBinding" 
           contract="Bla.IBlaAPI" 
           bindingConfiguration="BlaAPI.BindingConfig">

Binding config:

<binding name="BlaAPI.BindingConfig"
                 receiveTimeout = "10:50:00"
                 sendTimeout = "10:50:00"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transactionFlow="false">
          <readerQuotas maxDepth="32"
                       maxStringContentLength="2147483647"
                       maxArrayLength="2147483647"
                       maxBytesPerRead="8192"
                       maxNameTableCharCount="2147483647" />
          <security mode="None"/>
</binding>

Note that we are using long timeouts and have really high quotas for message size and etc. because we are passing some big chunks of data through this service. You can adjust for your own needs. We have the security set to "none" because the service is only being contacted from the local machine which is secured. Again, your mileage may vary.

Client:

<endpoint name="Bla.Bindings.BlaAPI" address="net.pipe://localhost/bla/IBlaAPI.svc"
                behaviorConfiguration="BlaAPI.ServiceBehavior"
                binding="netNamedPipeBinding" bindingConfiguration="BlaAPI.BindingConfig"
                contract="Bla.IBlaAPI" />

About the Faulted state problem, please note that if an unhandled exception occurs during execution of the service code, the service instance will remain in Faulted state until it is closed properly. To avoid this, either handle exceptions at service top-level or use, for example, Enterprise Library Excexption Handling blocks.

axel_c
Could you post up your binding configuration node? Also with your named pipes did you have to do anything with permissions or identities?
sipwiz
Done, added our binding config. Regarding security, we use "None" since all accesses are local.
axel_c
Looks like my issue with the netNamedPipeBinding is a Vista and/or IIS7 one. Even trying your exact same config it won't work for me on my Vista dev PC but works fine on my Win2k3/IIS6 server.
sipwiz
Our devel boxes are vista + iis7 (the 'light' IIS included in Vista). Make sure you enable all the relevant IIS features in the Vista features section of the control panel (Framework 3.0, ISAPI Extensions, ISAPI Filters, ASP.NET, Http Activation, Non-Http Activation, Windows Process Activation Service, .NET Environment, Configuration APIs,Process Model). Also check that you have enabled the net.tcp and net.pipe bindings in the IIS site you're running your services under...
axel_c