Permalink
Browse files

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.
  • Loading branch information...
bl8 committed Mar 24, 2012
1 parent 9988b56 commit 27beaafdb282c0721a8350825b1164b8d45119cb
Showing with 5 additions and 2 deletions.
  1. +5 −2 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);
}

0 comments on commit 27beaaf

Please sign in to comment.