I am trying to understand why a simple call to a feed works only when I have fiddler open.
I've looked at the below links, but none of the answers seem to apply:
HttpWebRequest doesn't work except when fiddler is running
HttpWebRequest only works while fiddler is running
http://blogs.telerik.com/fiddler/posts/13-02-28/help!-running-fiddler-fixes-my-app-
My code is very simple, and as far as I can see, it should just fill the variable with the contents of the xml file:
using (var client = new WebClient())
{
text = client.DownloadString(path);
}
Note that this works perfectly if I am running fiddler, but fails with a timeout error (?) if I run it while fiddler is not running.
I can access the path to the xml file directly from my broswer - so permissions/access does not appear to be a problem either.
http://www.tfl.gov.uk/tfl/syndication/feeds/cycle-hire/livecyclehireupdates.xml
The RAW output from Fiddler is:
HTTP/1.1 200 OK
Via: 1.1 varnish, 1.1 ZTMG01
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Transfer-Encoding: chunked
Age: 19
Date: Mon, 22 Dec 2014 15:23:47 GMT
Content-Type: text/xml
ETag: "dce1c05f259961aeac88cebcdfdbeebe"
Server: AmazonS3
x-amz-id-2: C6oNmRATZO4E7eNiyPhyCOhqT45Mb9Wp0XXaU8KsBQf84gYeNzM9OPAOa9YBNFsL4DGsPSEs5Cw=
x-amz-request-id: 0CE21B93AC8DDC15
Last-Modified: Mon, 22 Dec 2014 15:22:31 GMT
X-TTL-RULE: 8
X-Cacheable: Yes. Cacheable
X-TTL: 60.000
X-Backend: proxy
X-Varnish: 10.76.2.236
X-Backend-Url: http://s3-eu-west-1.amazonaws.com/tfl.pub/Serco/livecyclehireupdates.xml
X-Hash-Url: /tfl.pub/Serco/livecyclehireupdates.xml
Access-Control-Allow-Origin: *
X-Varnish: 181999945 181994842
X-Banning:
X-Cache: HIT
X-Cache-Hits: 4
Does anyone have any idea why this might be?
I can't see how this could be anything other than a proxy configuration issue on the development machine. I've tested the supplied code and URL using LINQPad, and retrieved the XML successfully, both with Fiddler running and not running.
You can override the default proxy configuration of a WebClient instance by setting the Proxy property to null:
string path = "http://www.tfl.gov.uk/tfl/syndication/feeds/cycle-hire/livecyclehireupdates.xml";
using (System.Net.WebClient client = new System.Net.WebClient())
{
client.Proxy = null;
client.DownloadString(path);
}
Note that setting Proxy to null will always bypass Fiddler.