Fiddler and NETMF/Gadgeteer

For folks who’ve not yet used it, Fiddler (Download Fiddler Web Debugging Tool for Free by Telerik now owned by Telerik) is a really useful web debugging tool. It sets itself up as a WinInet proxy, and records all traffic coming through your internet connection. It’s an essential tool for debugging HTTP traffic, particularly when calling REST-style APIs, which cannot be adequately tested via a browser.

One of the neat features that Fiddler offers is the ability to set it up as a proxy for external mobile devices (phones, tablets, etc.) so that you can test the traffic to/from that device as well. Lots of resources on this, but here’s one post that shows how to set this up:

My question…has anyone tried doing this with a NETMF/Gadgeteer device? The reason I ask is that I typically use DHCP exclusively, so while I know that you can set up your network adapter with a static IP, I wasn’t sure whether you can set the port number, as is shown in the setup for the iPad.

Would definitely be cool to be able to monitor the HTTP traffic from my Gadgeteer board, and when I have time, I’ll definitely try it, but I figured if others had already tried, successfully or unsuccessfully, that might save me some trial and error. :slight_smile:

3 Likes

@ devhammer - I to am looking to use Fiddler with my boards. Looking forward to a solution.

Haven’t tried it, but this looks like it should do the trick:

Sweet! :smiley:

Oh, and it looks like you need a reference to System.Http in your project to use this, and “using System.Net” if you don’t want to use the fully-qualified name for the WebProxy class.

In my hacker closet I keep an old Network Hub (not a switch but an old hub), that lets me ‘observe’ network traffic. The other thing I do is route network traffic through my laptop via a share network connection and then I can use various tools including fiddler to ‘observe’ that traffic.

You can observe traffic in your other job too!

Here is how I got it to work:

  1. Install and start fiddler
  2. Open Tools->Fiddler Options->Connections and click on “Allow remote computers to connect” (see screenshot)
  3. Configure a proxy as you see in the code below (The proxy address used is the ip address of the computer running Fiddler)
  4. When you run, you should see fiddler capture the interactions as seen in the second screenshot
  5. This can be made to work so that you can see the content of SSL interactions, but that is a fair bit more complicated. However, without SSL configuration, you will not see the content of SSL traffic. All you will see is the ‘tunnel’ messages showing that an SSL/TLS tunnel was established.
using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerAndFiddler
{
    public partial class Program
    {
        private WebProxy _proxy;

        void ProgramStarted()
        {
            Debug.Print("Program Started");

            ethernetJ11D.UseThisNetworkInterface();
            ethernetJ11D.UseStaticIP("192.168.1.200", "255.255.255.0", "192.168.1.1", new[] { "8.8.8.8", "8.8.4.4" });

            _proxy = new WebProxy("http://192.168.1.236:8888/", false);

            GT.Timer timer = new GT.Timer(10000); // every 10 seconds
            timer.Tick += timer_Tick;
            timer.Start();

        }

        void timer_Tick(GT.Timer timer)
        {
            var request = WebRequest.Create("http://www.example.com/");
            request.Proxy = _proxy;
            var response = request.GetResponse();
            using (var stream = response.GetResponseStream())
            {
                var reader = new StreamReader(stream);
                var responseString = reader.ReadToEnd();
                Debug.Print(responseString);
            }
        }
    }
}

2 Likes

@ mcalsyn - Thank you for that concise configuration explanation.