Fix: handling HttpStatusCode.InternalServerError

After all, it seems that all that was needed was to properly process HttpStatusCode.InternalServerError ...
This commit is contained in:
Gwyneth Llewelyn
2022-04-14 16:29:40 +01:00
parent 7130620f27
commit a28014bc29
2 changed files with 54 additions and 25 deletions

View File

@@ -24,7 +24,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System;
using System.Collections;
using System.Net;
using System.Threading;
using OpenMetaverse.StructuredData;
@@ -155,7 +156,37 @@ namespace OpenMetaverse.Http
break;
case (HttpStatusCode)499: // weird error returned occasionally, ignore for now
// I believe this is the timeout error invented by LL for LSL HTTP-out requests (gwyneth 20220413)
Logger.Log("Possible HTTP-out timeout error, no need to continue)", Helpers.LogLevel.Info);
Logger.Log($"Possible HTTP-out timeout error from {_Address}, no need to continue", Helpers.LogLevel.Debug);
_Running = false;
_Dead = true;
break;
case HttpStatusCode.InternalServerError:
// As per LL's instructions, we ought to consider this a
// 'request to close client' (gwyneth 20220413)
Logger.Log($"Grid sent a {code} at {_Address}, closing connection", Helpers.LogLevel.Debug);
// ... but do we happen to have an InnerException? Log it!
if (error.InnerException != null)
{
// unravel the whole inner error message, so we finally figure out what it is!
// (gwyneth 20220414)
Logger.Log($"Unrecognized internal caps exception from {_Address}: '{error.InnerException.Message}'", Helpers.LogLevel.Warning);
Logger.Log("\nMessage ---\n{error.Message}", Helpers.LogLevel.Warning);
Logger.Log("\nHelpLink ---\n{ex.HelpLink}", Helpers.LogLevel.Warning);
Logger.Log("\nSource ---\n{error.Source}", Helpers.LogLevel.Warning);
Logger.Log("\nStackTrace ---\n{error.StackTrace}", Helpers.LogLevel.Warning);
Logger.Log("\nTargetSite ---\n{error.TargetSite}", Helpers.LogLevel.Warning);
if (error.Data.Count > 0)
{
Logger.Log(" Extra details:", Helpers.LogLevel.Warning);
foreach (DictionaryEntry de in error.Data)
Logger.Log(String.Format(" Key: {0,-20} Value: {1}",
"'" + de.Key.ToString() + "'", de.Value),
Helpers.LogLevel.Warning);
}
// but we'll nevertheless close this connection (gwyneth 20220414)
}
_Running = false;
_Dead = true;
@@ -165,7 +196,11 @@ namespace OpenMetaverse.Http
// 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
// that we ignore
//
// Note: if this condition persists, it _might_ be the grid trying to request
// that the client closes the connection, as per LL's specs (gwyneth 20220414)
Logger.Log($"Grid sent a Bad Gateway Error at {_Address}; probably a time-out from the grid's EventQueue server (normal) -- ignoring and continuing", Helpers.LogLevel.Debug);
break;
default:
++_errorCount;
@@ -178,26 +213,20 @@ namespace OpenMetaverse.Http
}
else if (error.InnerException != null)
{
// There is a situation where the InnerException contains
// InternalServerError (the 500 HTTP code) although the
// code _is_ HttpStatusCode.OK. Keeping this open will
// leak memory massively!!
// As per LL's instructions, we ought to consider this a
// 'request to close client' even though it's improperly
// formatted... (gwyneth 202204139)
if (error.InnerException.Message == "InternalServerError")
// see comment above (gwyneth 20220414)
Logger.Log($"Unrecognized internal caps exception from {_Address}: '{error.InnerException.Message}'", Helpers.LogLevel.Warning);
Logger.Log("\nMessage ---\n{error.Message}", Helpers.LogLevel.Warning);
Logger.Log("\nHelpLink ---\n{ex.HelpLink}", Helpers.LogLevel.Warning);
Logger.Log("\nSource ---\n{error.Source}", Helpers.LogLevel.Warning);
Logger.Log("\nStackTrace ---\n{error.StackTrace}", Helpers.LogLevel.Warning);
Logger.Log("\nTargetSite ---\n{error.TargetSite}", Helpers.LogLevel.Warning);
if (error.Data.Count > 0)
{
Logger.Log("Grid sent us back an Internal Server Error, but HTTP code was 200, not 500 -- closing connection",
Helpers.LogLevel.Warning);
_Running = false;
_Dead = true;
break;
}
else
{
Logger.Log($"Unrecognized internal caps exception from {_Address}: {error.InnerException.Message}",
Helpers.LogLevel.Warning);
Logger.Log(" Extra details:", Helpers.LogLevel.Warning);
foreach (DictionaryEntry de in error.Data)
Logger.Log(String.Format(" Key: {0,-20} Value: {1}",
"'" + de.Key.ToString() + "'", de.Value),
Helpers.LogLevel.Warning);
}
}
else
@@ -206,7 +235,7 @@ namespace OpenMetaverse.Http
Helpers.LogLevel.Warning);
}
break;
}
} // end switch
#endregion Error handling
}