I am creating a windows service that starts a number of slave processes. In each of these slave process I start listening on a named pipe for message from the master process.
I currently have the situation where the master process calls a slave via a named pipe before the slave is fully started and starts listening on the named pipe.
ProcessStartInfo processStartInfo = new ProcessStartInfo("slave");
processStartInfo.Arguments = Address
Process process = new Process();
process.StartInfo = processStartInfo;
process.Start();
base.Endpoint.Binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
base.Endpoint.Address = Address;
base.Channel.RemoteMethod();
If I do this the channel gets into CommunicationState.Faulted
and any subsequent calls on the channel fail as well.
What can I do to verify from the master that the slave process starts listening? Or how can I recover from the CommunicationState.Faulted
to retry my remote call?
The only way to recover from the Faulted state is to reiniailize the WCF Client by re-building the instance and call the Open() method.
In general, before I call the service, I always check the Status property and if it is not Opened I try to reinitialize it as I described above. If it fails, there is a problem with the server. (In my case, the state gets faulted due to inactivity, so initialization ussually succedes)