What I am trying to do is have a wcf duplex service that multiple clients register to. When a client calls the service, the other clients are notified of the call.
Right now, I have a Silverlight app that calls a wcf duplex service. On the first call everything is working correctly including duplex communication. On the second call to the service I am getting a :
The communication object, System.ServiceModel.Channels.ClientPollingDuplexSessionChannel, cannot be used for communication because it is in the Faulted state.
My service has 2 different methods; RegisterClient and ReassignOwner. If I call the same method twice or both method once in any order I am still getting this error.
After researching on the subject I thought it might be a timeout problem. I checked what the default timeout value was and it's 10 minutes. I do both calls within the span of 2-3 minutes tops. I have also increased the Inactivity timeout and the Receive timeout to 4 hours just to be sure and I am still getting this problem.
Next, I thought my service might be generating an exception which would cause the client to go in a faulted state. To test this, I have put try/catch statements in the 2 methods of my service and ran the program in debug mode. I did not catch any exception. I also tried commenting out all the code from those 2 methods (so no exception can be generated) and just calling those 2 empty methods and I still got the exception.
By reading other related post here on SO, I decided to try WCF tracing. I enabled it in my web.config and set the switch value to Warning. I get 2 warnings:
Description Faulted System.ServiceModel.Channels.ServicePollingDuplexSessionChannel
Description Faulted System.ServiceModel.Channels.ServiceChannel
Here is how my service is defined in the code behind .svc.cs file:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, AutomaticSessionShutdown = false)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class NotificationService : BaseService, INotificationDuplexService
In my service contract my methods both have the following attributes:
[OperationContract(AsyncPattern = true, IsOneWay = true,
Action = "http://www.abc.org/NotificationDuplex/INotificationDuplexService/MethodName")]
Both my methods are implemented in an async fashion with a Begin and an End method.
Here is how I invoke my methods
base.InvokeAsync(this.onBeginRegisterClientDelegate, new object[] {
id}, this.onEndRegisterClientDelegate, this.onRegisterClientCompletedDelegate, userState);
Anybody know why this is happening or have any clue to how I could continue trying to solve this problem ?
Finally I have found the awnser in a similar question : Silverlight PollingDuplex InnerChannel faulted with multipleMessagesPerPoll (serverPollTimeout)
It seems there is a bug when you set the PollingDuplexHttpBinding to PollingDuplexMode.MultipleMessagesPerPoll and you run your application under IE 8 (other browsers aren't affected).
The solution is to put the PollingDuplexMode to SingleMessagePerPoll which is less performant but focntionnal in IE8.