I've tried to make an inter-server communication protocol with WCF. But for some reason, when a server disconnects, the Faulted neither the Closed events are called. This is really annoying but I haven't found a solution to it.
private static ServiceHost loginService;
static void Load() {
loginService = new ServiceHost(typeof(LoginService), new Uri[] { new Uri(Settings.Instance.LoginServiceURI) });
loginService.AddServiceEndpoint(typeof(ILoginService), ServiceHelpers.GetBinding(new Uri(Settings.Instance.LoginServiceURI)), Settings.Instance.LoginServiceURI);
loginService.Faulted += new EventHandler(loginService_Faulted);
loginService.Open();
}
static void loginService_Faulted(object sender, EventArgs e)
{
Log.WriteLine(LogLevel.Error, "LoginWCF Faulted. Restarting.");
loginService.Close();
Load();
}
The stupid thing is that only the functions inside the ILoginService interface will throw an exception when the connection died. I thought that TCP had a keep-alive of it's own?