From 27beaafdb282c0721a8350825b1164b8d45119cb Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Sat, 24 Mar 2012 13:03:26 +0100 Subject: [PATCH] ControlClient: Retry the request in case of timeout The Helper.GetResponse method will retry once if we get a "Gateway Timeout" HTTP response code. Also add some additional log output for some error cases. --- .../Mono.Upnp/Mono.Upnp.Internal/ControlClient.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Mono.Upnp/Mono.Upnp/Mono.Upnp.Internal/ControlClient.cs b/src/Mono.Upnp/Mono.Upnp/Mono.Upnp.Internal/ControlClient.cs index 0451775c..fb418db6 100644 --- a/src/Mono.Upnp/Mono.Upnp/Mono.Upnp.Internal/ControlClient.cs +++ b/src/Mono.Upnp/Mono.Upnp/Mono.Upnp.Internal/ControlClient.cs @@ -75,12 +75,13 @@ public ControlClient (string serviceType, Uri url, XmlDeserializer deserializer) HttpWebResponse response; WebException exception; try { - response = (HttpWebResponse)request.GetResponse (); + response = Helper.GetResponse (request); exception = null; } catch (WebException e) { response = e.Response as HttpWebResponse; if (response == null) { - // TODO check for timeout + Log.Error (string.Format ( + "The request for the {0} action request on {1} failed.", actionName, url)); throw new UpnpControlException (UpnpError.Unknown(), "The invokation failed.", e); } exception = e; @@ -137,6 +138,8 @@ public ControlClient (string serviceType, Uri url, XmlDeserializer deserializer) "The invokation failed but the service did not provide valid fault information " + "(unable to deserialize a UPnPError from the SOAP envelope).", exception); } + Log.Error (string.Format ( + "The invokation for the {0} action request on {1} failed: {2}", actionName, url, envelope.Body.Value.Detail.Value)); throw new UpnpControlException (envelope.Body.Value.Detail.Value, "The invokation failed.", exception); }