views:

30

answers:

1

I have a WCF Service which I am calling asychronously.

If I call a method that throws a normal .Net Exception (i.e., not a FaultException) using wsHttpBinding, my WCF Channel is left in a faulted state - this is the expected behavior.

However, if I call the same method using a custom binding:

<customBinding>
   <binding name="httpCompressed" sendTimeout="00:10:00" receiveTimeout="00:10:00">
      <httpTransport maxBufferSize="2147483647"
            maxBufferPoolSize="524288"
            maxReceivedMessageSize="2147483647" />
   </binding>
</customBinding>

Then, while I do receive an exception back, the channel is left in an Open state. This is not an expected behavior - at least, not as far as I can tell.

Is this indicative of a bug in the customBinding for WCF? Is this actually an expected behavior (if so, a pointer documentation would be excellent).

Thanks in advance for any assistance.

David Mullin IMA Technologies

A: 

This is expexted. WsHttpBinding in default setting (with security session) uses PerSession instancing. It means that single service instance handles all requests from proxy opening the channel. If unhandled exception occures the service instance is destroyed and channel is faulted. Proxy can't open more than one channel and can't start another session so the only thing you can do with faulted proxy is to abort it.

Your custom binding uses pure http transport without any session. Due to that PerCall instancing is used. It means that each request from proxy is handled by new service instance. Service instance is released after each call and faults don't affect the channel because next call will be handled by a new service instance.

Ladislav Mrnka
Hmm. Given that, I would expect that explicitely changing the instancing of my Service as follows:[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]would make it so that, if I used wsHttpBinding, I would no longer end up with a faulted channel. That is not the case - I've tried all different permutations of instancing/concurrency, and I consistently get the behavior that wsHttpBinding faults, and customBinding does not.
David Mullin
It is probably not clear from my response but what matters here is a session. Even if you use Single instance mode in the service exposed over your custom binding you still don't have session.
Ladislav Mrnka