From acb59f606f949d8687146d04cd27995bcb4141a6 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 9 Jul 2008 23:20:45 +0000 Subject: [PATCH] * Apparently the CAPS server does not support keep-alive at all (see http://jira.secondlife.com/browse/SVC-2628), so support for it has been completely disabled and the connection reuse timeout is 100x more aggressive now * The 502 errors are unofficially part of the protocol (see http://jira.secondlife.com/browse/SVC-2629), so the event queue logging has been cleaned up and no longer emits messages for those. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1908 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/Capabilities/CapsBase.cs | 4 ++- .../Capabilities/EventQueueClient.cs | 32 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libsecondlife/Capabilities/CapsBase.cs b/libsecondlife/Capabilities/CapsBase.cs index 2beb6452..0938c271 100644 --- a/libsecondlife/Capabilities/CapsBase.cs +++ b/libsecondlife/Capabilities/CapsBase.cs @@ -423,6 +423,8 @@ namespace libsecondlife.Capabilities // Disable keep-alive by default request.KeepAlive = false; + // Set the closed connection (idle) time to one second + request.ServicePoint.MaxIdleTime = 1000; // Disable stupid Expect-100: Continue header request.ServicePoint.Expect100Continue = false; // Crank up the max number of connections (default is 2!) @@ -442,7 +444,7 @@ namespace libsecondlife.Capabilities { HttpWebRequest request = (HttpWebRequest)SetupRequest(address); // Re-enable Keep-Alive - request.KeepAlive = true; + //request.KeepAlive = true; try { diff --git a/libsecondlife/Capabilities/EventQueueClient.cs b/libsecondlife/Capabilities/EventQueueClient.cs index 4495f882..42b4424e 100644 --- a/libsecondlife/Capabilities/EventQueueClient.cs +++ b/libsecondlife/Capabilities/EventQueueClient.cs @@ -145,19 +145,39 @@ namespace libsecondlife.Capabilities } else if (!e.Cancelled) { - if (Helpers.StringContains(message, "502")) + // Figure out what type of error was thrown so we can print a meaningful + // error message + if (e.Error is WebException) { - Logger.DebugLog("502 error from event queue " + _Client.Location); + WebException err = (WebException)e.Error; + HttpWebResponse errResponse = (HttpWebResponse)err.Response; + + switch (errResponse.StatusCode) + { + case HttpStatusCode.BadGateway: + // This is not good (server) protocol design, but it's normal. + // The EventQueue server is a proxy that connects to a Squid + // cache which will time out periodically. The EventQueue server + // interprets this as a generic error and returns a 502 to us + // that we ignore + break; + default: + Logger.Log(String.Format( + "Unrecognized caps connection problem from {0}: {1} (Server returned: {2})", + _Client.Location, errResponse.StatusCode, errResponse.StatusDescription), + Helpers.LogLevel.Warning); + break; + } } else if (e.Error.InnerException != null) { - Logger.Log("Unrecognized caps exception from " + _Client.Location + - ": " + e.Error.InnerException.Message, Helpers.LogLevel.Warning); + Logger.Log(String.Format("Unrecognized caps exception from {0}: {1}", + _Client.Location, e.Error.InnerException.Message), Helpers.LogLevel.Warning); } else { - Logger.Log("Unrecognized caps exception from " + _Client.Location + - ": " + e.Error.Message, Helpers.LogLevel.Warning); + Logger.Log(String.Format("Unrecognized caps exception from {0}: {1}", + _Client.Location, e.Error.Message), Helpers.LogLevel.Warning); } } }