-
-
Notifications
You must be signed in to change notification settings - Fork 94
Debugging with Fiddler
Fiddler is a proxy program that helps debug HTTP and HTTPS traffic by setting up a local proxy and passing all web traffic through the local Fiddler proxy. When web traffic flows through the a local Fiddler proxy, HTTP and HTTPS traffic is available for inspection.
The following instructions demonstrate how to set up a local Fiddler Proxy to debug a .NET Application using HTTP or HTTPS.
- Download Telerik Fiddler here.
The following configures Fiddler to decrypt HTTPS traffic by installing and trusting a self-signed trusted "root certificate" in the local computer's "root certificate" store.
- Go to
Tools > Fiddler Options...
. Click onHTTPS
tab.- Enable
Capture HTTPS CONNECTs
. - Enable
Decrypt HTTPS traffic ...from all processes
. - Follow all prompts to install the Root Certificate.
- Click Ok to save settings.
- Enable
💡 Note: If you didn't receive any prompt to install a Root Certificate, click the Actions > Trust Root Certificate
button.
The following configures Fiddler to listen on a local port for proxy traffic.
- Go to
Tools > Fiddler Options...
. Click onConnections
tab.- Set
Fiddler listens on port: 8888
. - Enable
Allow remote computers to connect
. - Click Ok to save settings.
- Set
Reboot the computer.
💡 Reduce Noise: By default Fiddler will start capturing traffic from all applications at start up. Since we are only interested in debugging local traffic from a single .NET Application you can reduce noise by disabling capturing of live traffic and clearing the traffic traces:
- Press F12 or uncheck
File > Capture Traffic
. - Clear the requests list:
Keep Fiddler running in the background. Fiddler will continue to capture any traffic that passes through the localhost
proxy even when Capture Traffic
is disabled.
Next, instruct your .NET Application to use the local Fiddler proxy for HTTP / HTTPS requests.
For this Coinbase Client library, use the EnableFiddlerDebugProxy
helper setup method that configures the underlying HttpClient
to use the localhost
proxy shown below:
var cfg = new Coinbase.ApiKeyConfig
{
ApiKey = "fff",
ApiSecret = "ggg"
};
var c = new Coinbase.CoinbaseClient(cfg);
c.EnableFiddlerDebugProxy("http://localhost.:8888");
var price = await c.Data.GetBuyPriceAsync("BTC-USD");
price.Data.Dump();
💡 Note: Be sure to include the .
period at the end of the localhost.
in the proxy URL. This is not a typo.
Next, compile and run the .NET Application and invoke any methods that would cause the .NET Application to send a web request.
Finally, check the Fiddler window to inspect HTTP and HTTPS traffic as shown below:
- Select the HTTP request.
- Click the Inspectors tab.
- Click the TextView or other response tabs to inspect the response.
The captured traffic from Fiddler should allow you to finally diagnose your issue. Copy, paste, and screenshot any output from Fiddler to a third-party to help debug issues you might be having.
In general cases, it may be desirable to configure raw a HttpClient
to use the localhost
Fiddler proxy. The following code example shows how to setup an HttpClient
to use the localhost
proxy:
var handler = new HttpClientHandler()
{
Proxy = new WebProxy("http://localhost.:8888", BypassOnLocal: false),
UseProxy = true
};
var client = new HttpClient(handler);
var r = await client.GetAsync("https://www.google.com");
To debug HTTP and HTTPS traffic from remote clients you'll need to use a MITM (man-in-the-middle) technique. See the following blog post for more information: