Pete Pete - 3 months ago 22
C# Question

What could stop default proxy being used

As my question about manually setting a proxy for the google youtube v3 api has not yielded any results. I thought I would ask a seperate question as to what the causes of the proxy not being used are.

As stated in my other question, I have set the following in my web.config:

<defaultProxy useDefaultCredentials="false" enabled="true">
<proxy usesystemdefault="False" proxyaddress="http://192.111.111.102:8081" />
</defaultProxy>


Which by all accounts should mean that the google api will use the proxy and port stated

Yet I am still getting a connection refused error. Having looked into this with the systems team, it looks as if the request to the google api doesn't hit the proxy at all.

So my new question is what would cause this setting to be ignored and is there any other way of setting a default proxy?

Answer

Not sure what was stopping the default proxy being used as it would work sometimes but then randomly not on other occasions, in the end I went with coding in a redundancy for when the default proxy failed to work:

private VideoListResponse GetVideoListReponse(string videoIds) 
{
  // this is original call
  VideoListResponse response = GetVideoListReponseFromAPI(videoIds);
  if (response == null) 
  {
    // if original call fails, use a webrequest where I can set the proxy manually
    return GetVideoListReponseFromWebRequest(videoIds);
  } else {
    return response;
  }
}

See this answer for how I set my proxy manually