- July 25, 2010
- 4,024
- 1,420
- Home Country
- Germany
- Thread starter
- #91
In fact I already do:an you try to encapsulate errors/exceptions at a high level and log them?
Code:
public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
{
var uri = request.Uri;
Guid mediaItemGuid = Guid.Empty;
bool bHandled = false;
Logger.Debug("MainRequestHandler: Received request {0}", request.Uri);
try
{
response.AddHeader("Server", _serverOsVersion + _product);
response.AddHeader("Cache-control", "no-cache");
response.Connection = ConnectionType.Close;
// Check the request path to see if it's for us.
if (!uri.AbsolutePath.StartsWith(RESOURCE_ACCESS_PATH))
{
return false;
}
// Pass the Processing to the right module
string[] uriParts = uri.AbsolutePath.Split('/');
Logger.Info("MainRequestHandler: AbsolutePath: {0}, uriParts.Length: {1}", uri.AbsolutePath, uriParts.Length);
if (uriParts.Length > 2)
{
// The URL shoud look like this: /MPExtended/MediaAccessService/json/GetServiceDescription
IRequestModuleHandler requestModuleHandler;
if (_requestModuleHandlers.TryGetValue(uriParts[2], out requestModuleHandler))
requestModuleHandler.Process(request, response, session);
else
ServiceRegistration.Get<ILogger>().Warn("RequestModule not found: {0}", uriParts[2]);
}
}
catch (Exception ex)
{
throw new InternalServerException("Failed to proccess! - Exception: {0}", ex);
}
return true;
}
As you can see everything is in a Try Catch blog and this is the Main module. So every call to the HTTP Server goes to all registered modules. And inside the try catch this module determined if the request is handled by this module, if not, it returns with false.
Should there happen something fatal it will delivere an Exception to the user. The "Exception..." page you see it coming from this try catch. So I think it is unlikely that one of the modules is taking the server down. Does that make sense?
Yeah, my dad had birthday, so I won't have too much time over the weekend, too. Big PartyNot sure how much time I will have, maybe a bit this evening but then I'm away Friday and during the weekend.
I just delivere it vie http to the browser, but it might be a good idea to also log it. Will add an Log entry before thrwoing the errorNone of the issues we have had so far has been visible in the log
I write all requests as you can see by this two calls:developing so you both write all requests and also replies for them
Code:
Logger.Debug("MainRequestHandler: Received request {0}", request.Uri);
Your debug level is probably set to Info and not to debug Here is explained how to change the debug level
http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/6_Support/4_Bug_reports_and_log_files
I can also add the replies to the log file, but this will slow down responses (I experienced that during the MediaServer development). So I can add this, but expect some slower answers.