Merge pull request #1201 from Frezzle/CA-214653

CA-214653: Work-around for XC reconnecting to proxy server with new wrong credentials
This commit is contained in:
Konstantina Chremmou 2016-10-13 14:20:25 +01:00 committed by GitHub
commit ea9c8a2040

View File

@ -131,7 +131,7 @@ namespace XenAdmin.Network
// Now that we've successfully received a heartbeat, reset our 'second chance' for the server to timeout
if (retrying)
log.DebugFormat("Heartbeat for {0} has come back", session == null ? "null" : session.Url);
log.DebugFormat("Heartbeat for {0} has come back", session.Url);
retrying = false;
}
catch (TargetInvocationException exn)
@ -146,13 +146,31 @@ namespace XenAdmin.Network
log.Error(exn);
}
HandleConnectionLoss();
return;
}
catch (WebException exn)
{
log.Error(exn);
if (((HttpWebResponse)exn.Response).StatusCode == HttpStatusCode.ProxyAuthenticationRequired) // work-around for CA-214653
{
if (session == null)
log.Debug("Heartbeat has failed due to null session; closing the main connection");
else if (session.proxy.Proxy.Credentials == null)
log.DebugFormat("Heartbeat for {0} has failed due to missing credentials; closing the main connection", session.Url);
else
log.DebugFormat("Heartbeat for {0} has failed due to incorrect credentials; closing the main connection", session.Url);
connection.Interrupt();
DropSession();
}
else
{
HandleConnectionLoss();
}
}
catch (Exception exn)
{
log.Error(exn);
HandleConnectionLoss();
return;
}
}