Anyone got IIS working reliably as a WCF client

筅森魡賤 提交于 2019-12-06 15:08:04

问题


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?


回答1:


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.




回答2:


Re NetNamedPipeBinding and "There was no endpoint listening at net.pipe://localhost/mypipename"

Is your web application impersonating its users? The above error is what you get if you try to access a WCF service via the named pipe binding, in a security context whose logon token has membership of NETWORK USERS. The WCF client-side channel stack doesn't distinguish between access denied errors and "not found" errors, when it attempts to read the shared memory object created by the service to publish the name of the pipe in use. (See http://blogs.charteris.com/blogs/chrisdi/archive/2008/05.aspx etc)

Impersonation tokens in an IIS application will always have NETWORK USERS membership.




回答3:


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.



来源:https://stackoverflow.com/questions/1707518/anyone-got-iis-working-reliably-as-a-wcf-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!