Using Fiddler to monitor network traffic from the VS Emulator for Android
In today’s cloud-connected world, it’s hard to find an app that doesn’t make use of an internet connection in some way or another. Whether you’re collecting app usage telemetry, making calls to a web service, or uploading your users’ cat pictures to Facebook, ensuring that your app can reliably communicate with the web is critical to developing a high quality product.
You already know that the Visual Studio Emulator for Android
Step One: Install the latest versions of the emulator and Fiddler
Network monitoring is only possible with versions of the emulator greater than or equal to 50427.1. To figure out which version of the emulator you are running, go to Add/Remove Programs and look for the “Microsoft Visual Studio Emulator for Android” entry.
Now you’re ready to get started configuring the emulator to proxy network traffic through Fiddler.
Step Two: Configure Fiddler
Open Fiddler and go to Tools > Fiddler Options. Under the “Connections” tab:
- Check “Allow remote computers to connect”
- Check “Reuse client connections”
- Check “Reuse server connections”
- Check “Monitor all connections”
- If you want to view traffic from both the emulator and your host PC, check “Act as system proxy on startup”
- Write down the port listed under “Fiddler listens on port” (the default is 8888).
Your Connections tab should now look something like this:
Hit “OK.” Now hover over the Online indicator in the top right of the Fiddler window, and record the last IP address listed—this is the IP address that will be visible to the emulator. For example, in the screenshot below, my IP address is 10.82.33.138.
Now, close Fiddler. This is an important step—if Fiddler is running when you start the emulator, it will interfere with the emulator’s startup processes and prevent the emulator from starting.
Step Three: Configure the emulator
With Fiddler closed, start your emulator. You can start the emulator by either hitting F5 in a Visual Studio Cross-Platform project type (VC++, Cordova, or Xamarin), or by pressing the play button in the Emulator Manager, available in Visual Studio 2015 under the Tools > “Visual Studio Emulator for Android…” option.
Once the emulator is running, in Android hit the Launcher button, go to the Settings app, and open WiFi settings. Now, click and hold on the WiFi network that appears (should be “Wired eth1”). A dialog will appear like this:
Click “Modify network” then check “Advanced options.” If you accidentally click “Forget network,” you’ll need to reboot the emulator for it to find the simulated WiFi network again. Now, set the Proxy dropdown to “Manual.”
Fill in the “Proxy hostname” textbox with the IP address you wrote down from Fiddler above and the “Proxy port” textbox with the port you wrote down from Fiddler Options > Connections tab (“Fiddler listens on port”).
Step Four: Enjoy monitoring network traffic of your app running in the emulator
Now, reopen Fiddler and you are ready to go! Note that if Fiddler does not have an exception/allowance to run through your firewall, you will first need to create one–otherwise Fiddler will not be able to receive messages and the emulator will appear to be unable to connect to the internet.
If you have HTTPS traffic decryption on (under the HTTPS tab in Fiddler Options), Android will display a certificate warning.
I hope that this helps you get up and running with monitoring network traffic using the Visual Studio Emulator for Android. If you have any additional questions or suggestions, feel free to drop me a line in the comments below or ask us questions on StackOverflow