I have a computer that is running a single program that manages up to 48 individual processes on 4 other computers. I have the WCF services (one for each process) set up as such:
public void StartService(Uri uri, string identifier)
{
unitMetaData = identifier;
var binding = new WSDualHttpBinding(WSDualHttpSecurityMode.None);
binding.ReliableSession.InactivityTimeout = TimeSpan.FromDays(20);
var reader = binding.ReaderQuotas as XmlDictionaryReaderQuotas;
reader.MaxStringContentLength = WCFContentSize; // 16777216
service = new ServiceHost(this, uri);
service.Faulted += TestService_Faulted;
service.AddServiceEndpoint(
typeof(IController),
binding,
identifier);
service.Open();
}
Here is the code for the remote processes:
public void Connect()
{
// External binding used to change the WCF XML text content size
var binding = new WSDualHttpBinding(WSDualHttpSecurityMode.None);
binding.ReliableSession.InactivityTimeout = TimeSpan.FromDays(20);
var reader = binding.ReaderQuotas as XmlDictionaryReaderQuotas;
reader.MaxStringContentLength = WCFContentSize; // 16777216
DuplexChannelFactory<IController> factory = new DuplexChannelFactory<IController>(new InstanceContext(this), binding);
controllerChannel = factory.CreateChannel(new EndpointAddress(controllerAddress, new DnsEndpointIdentity(controllerAddress.DnsSafeHost), new System.ServiceModel.Channels.AddressHeaderCollection()));
((IClientChannel)controllerChannel).OperationTimeout = TimeSpan.FromSeconds(ChannelOperationTimeoutInSeconds); // 300
controllerChannel.RequestTestData();
}
I have some code that will call a remote "Ping()" function that simply returns the string "Pong" about every 30 seconds on each remote process. I did this to ensure that the connection stays open as I had some issue with the ReliableSession timing out. Occasionally (as in much too often for production code) I get the following exception from one and usually more services that test processes are connecting to:
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServerReliableDuplexSessionChannel, cannot be used for communication because it is in the Faulted state.
Server stack trace:
at System.ServiceModel.Channels.TransmissionStrategy.WaitQueueAdder.Wait(TimeSpan timeout)
at System.ServiceModel.Channels.TransmissionStrategy.InternalAdd(Message message, Boolean isLast, TimeSpan timeout, Object state, MessageAttemptInfo& attemptInfo)
at System.ServiceModel.Channels.ReliableOutputConnection.InternalAddMessage(Message message, TimeSpan timeout, Object state, Boolean isLast)
at System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.DuplexChannel.Send(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SEL.MfgTestDev.ESS.ServiceContracts.ITestProcessClient.Ping()
at SEL.MfgTestDev.ESS.Testing.Service.TestService.Ping() in C:\Projects\Mfg_TestDev_ESS_Rev3\branches\MSU-5-18-2010\ESS.Testing.Service\TestService.cs:line 349
So what's going on? Why is it suddenly ending up in a faulted state. Is there a way I can get the reason why a connection has faulted?