Skip to content

Commit

Permalink
ControlClient: Retry the request in case of timeout
Browse files Browse the repository at this point in the history
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 27beaaf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Mono.Upnp/Mono.Upnp/Mono.Upnp.Internal/ControlClient.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 27beaaf

Please sign in to comment.