I want to run Fiddler to help debug a portable API client that I'm developing.
In Visual Studio, on the Windows Store Unit Test project property page > Debug tab I have checked the 'Allow Local Network Loopback' option.
Every web request run during a store unit test fails with a System.Net.Sockets.SocketException
: A connection attempt failed because the connected party did not properly respond after a period of time or established connection failed because connected host has failed to respond 127.0.0.1:8888
.
The Uri I'm connecting to is not local - but another machine on the local network - so this fiddler loopback address is indeed coming from the global proxy setting.
I know that for Windows Store Apps you have to enable the loopback network isolation exemptions and have ticked every app container listed in the UI for that (despite none of them being related to VS or this unit test projects) - to no avail.
I've also tried disabling IPv6 in Fiddler - don't know why I thought that might work, but it was worth a punt - it didn't work either.
Anyone got any ideas!?
Okay - whilst I was on the right track, thinking that there must be some app container registered for the unit test project - what I didn't think was that it might only be active while MSTest is running.
You need to debug the Windows Store unit test (any of the tests in the project) and stick a breakpoint in (to halt execution of the test runner) so it will then appear in the list of AppContainers within Fiddlers' Loopback Extensions tool.
So - given this test:
[TestMethod]
public async Task Example()
{
var result = await GetSomeData(); //<-- breakpoint
Assert.IsNotNull(result);
}
private async string GetSomeData()
{
//TODO something that makes a web request with, say, HttpClient
}
All you do is breakpoint the line shown above - and then launch the 'Win8 Config' option from Fiddler - and you'll see that your unit tests project appears in the list of AppContainers.
Enable loopback for that app container, save the changes and then continue in your unit test - you should see the traffic correctly captured.
After doing this once it would seem that you don't have to do it again - I've closed down fiddler and restarted it and the traffic is still captured correctly.
One word of warning, however, once you do this the Loopback exemptions tool will moan about an exemption being defined for a SID for which there is no AppContainer if it is launched - unless you happen to be running a unit-test again.