home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Plugin Development
Featured Plugins
MP2Extended
Plugin: MP2Extended
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="FreakyJ" data-source="post: 1155673" data-attributes="member: 106003"><p>In fact I already do:</p><p>[CODE=C#]public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)</p><p> {</p><p> var uri = request.Uri;</p><p> Guid mediaItemGuid = Guid.Empty;</p><p> bool bHandled = false;</p><p></p><p> Logger.Debug("MainRequestHandler: Received request {0}", request.Uri);</p><p></p><p> try</p><p> {</p><p> response.AddHeader("Server", _serverOsVersion + _product);</p><p> response.AddHeader("Cache-control", "no-cache");</p><p> response.Connection = ConnectionType.Close;</p><p></p><p> // Check the request path to see if it's for us.</p><p> if (!uri.AbsolutePath.StartsWith(RESOURCE_ACCESS_PATH))</p><p> {</p><p> return false;</p><p> }</p><p></p><p></p><p> // Pass the Processing to the right module</p><p> string[] uriParts = uri.AbsolutePath.Split('/');</p><p> Logger.Info("MainRequestHandler: AbsolutePath: {0}, uriParts.Length: {1}", uri.AbsolutePath, uriParts.Length);</p><p> if (uriParts.Length > 2)</p><p> {</p><p> // The URL shoud look like this: /MPExtended/MediaAccessService/json/GetServiceDescription</p><p> IRequestModuleHandler requestModuleHandler;</p><p> if (_requestModuleHandlers.TryGetValue(uriParts[2], out requestModuleHandler))</p><p> requestModuleHandler.Process(request, response, session);</p><p> else</p><p> ServiceRegistration.Get<ILogger>().Warn("RequestModule not found: {0}", uriParts[2]);</p><p> }</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> throw new InternalServerException("Failed to proccess! - Exception: {0}", ex);</p><p> }</p><p></p><p> return true;</p><p> }[/CODE]</p><p></p><p>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.</p><p></p><p>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?</p><p></p><p></p><p>Yeah, my dad had birthday, so I won't have too much time over the weekend, too. Big Party <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /></p><p></p><p></p><p>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 error <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /></p><p></p><p></p><p>I write all requests as you can see by this two calls:</p><p>[CODE=C#] Logger.Debug("MainRequestHandler: Received request {0}", request.Uri);[/CODE]</p><p></p><p>Your debug level is probably set to Info and not to debug <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /> Here is explained how to change the debug level</p><p><a href="http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/6_Support/4_Bug_reports_and_log_files" target="_blank">http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/6_Support/4_Bug_reports_and_log_files</a></p><p></p><p>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.</p></blockquote><p></p>
[QUOTE="FreakyJ, post: 1155673, member: 106003"] In fact I already do: [CODE=C#]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; }[/CODE] 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 Party :D 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 error ;) I write all requests as you can see by this two calls: [CODE=C#] Logger.Debug("MainRequestHandler: Received request {0}", request.Uri);[/CODE] Your debug level is probably set to Info and not to debug :) Here is explained how to change the debug level [URL]http://wiki.team-mediaportal.com/2_MEDIAPORTAL_2/6_Support/4_Bug_reports_and_log_files[/URL] 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. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
Featured Plugins
MP2Extended
Plugin: MP2Extended
Contact us
RSS
Top
Bottom