Nico's digital footprint

I grew up in the nineties, that makes me awesome by default

Windows Phone 8 and Fiddler

by Nico

Fiddler and the WP8 emulator

Fiddler is a great tool for capturing network traffic. I find it especially useful when I’m working with services. It sniffs out your network traffic and allows you to dig into every incoming or outgoing request. You can even create requests from inside the tool. The tool itself is free to use and can be downloaded from https://fiddler2.com/fiddler2/

So how does it work? Fiddler installs a proxy on your machine (default on port 8888). That proxy intercepts all network traffic going from and to the machine it’s installed on. That traffic gets displayed in the Fiddler UI. The proxy captures the traffic, sends it to the application and let the traffic itself pass to the original destination. This image shows the normal client – internet situation (top half) and the situation with Fiddler installed (bottom half).

Makes sense? Nothing to difficult about this. What I just explained here is the basic functionality of Fiddler. Only monitoring your local traffic. The Windows Phone 8 emulator runs as a Hyper-V virtual machine, meaning it identifies itself as a separate device on the network. But that’s not really a problem, Fiddler in al its greatness can monitor remote devices as well. Here’s how to enable it.

First, start Fiddler and go to Tools > Fiddler options. Go to tab “Connections” and check the “Allow remote computers to connect” option.

Click OK, back on the Fiddler main screen, you’ll notice a textbox underneath the list of captured requests (a black one). That’s called the QuickExec box, it can be used to set preferences. In our case we need to add a hostname to our proxy. The hostname we need to add is the one from the Hyper-V host that is running the Windows Phone emulator, your developer machine in other words. Since all traffic from the Windows Phone emulator goes through our developer machines we need to attach Fiddler to our pc. The default localhost connection won’t work so we need to attach the Fiddler proxy to the network name.

In the QuickExec box enter this command

prefs set fiddler.network.proxy.registrationhostname <your computername>

With that done, restart Fiddler and the Windows Phone emulator and behold the emulator’s traffic getting sniffed. As you can see on the screenshot below, if I use the mobile browser in the emulator to go to my blog Fiddler captures all the images, pages, scriptfiles etc. that are getting loaded. If I select one, the user agent clearly points to the Windows Phone 8 browser.

Note that it doesn’t just captures the emulator’s traffic, all the localhost traffic is still captured as well.

Keep in mind that if you close Fiddler now there’s a chance that the Windows Phone emulator won’t have network access anymore, that’s because at startup it configured the Fiddler proxy as gateway, closing Fiddler means disabling the proxy. Simply restart the emulator and it should work fine again.

This is all great stuff, but eventually we’ll run into a situation where we need to sniff network traffic but for some reason we can’t use the emulator. With Fiddler we can also sniff the network traffic from an actual Windows Phone device, provided the machine running Fiddler and the Windows Phone are connected to the same network.

Fiddler and WP8 devices

To do this, setup Fiddler the same way as we did for the emulator. When that’s done, on you Windows Phone device go to Settings > WiFi. Select the wireless network that your phone is connected to and enable the Proxy. Set the proxy url to the IP address or the hostname of the computer running Fiddler and the port to 8888.

Fire up Fiddler, fire up the mobile browser on your phone and be amazed!

If you’re decrypting HTTPS traffic you might need to install the Fiddler certificate on your phone, the browser will prompt you to install it. Before testing your app with HTTPS, try the browser first so the certificate gets installed. Do be aware that every Fiddler installation generates its own certificate (they are self-signed so you might get a security warning, in this case its perfectly safe to ignore that warning) so you might need to install a new one when you use Fiddler on another machine.

 

Conclusion

In this post we’ve talked about using Fiddler, a great tool for sniffing and decrypting network requests, with both the Windows Phone 8 emulator and Windows Phone 8 devices. It’s really easy to setup and a great asset when working or developing services.

A few remarks to end this post:

If you ever change your computer’s hostname Fiddler will stop capturing Windows Phone network. Use the prefs set fiddler.network.proxy.registrationhostname <your computername> command again in the QuickExec box with the new hostname and Fiddler will happily continue its work.

If you computer is joined to a domain that has IPSEC security setup you will need to ask the administrator to add a IPSEC Boundary Computer exception for your computer.

Happy sniffing!


Tags:

.Net | WP7 | WP8 | Devices

Comments (14) -

venetasoft
venetasoft Italy
1/9/2013 6:40:00 AM #

Great article, thank you !!

Reply

Nico
Nico Belgium
1/9/2013 8:07:01 AM #

You're welcome Smile Glad you like it

Reply

Ela
Ela Poland
3/20/2013 2:14:19 PM #

What I found here sounds quite interesting. I shall visit this place more often. Keep on posting!

Reply

Sofi
Sofi Sweden
3/27/2013 11:44:28 AM #

Hi,
I've tried to do all this multiple times, but it doesn't work for me. Usually I can't access the web at all from the WP8 emulator. Sometimes I can access the web from the emulator, but fiddler doesn't track it.
I know it has worked earlier (in december, but I've reinstalled fiddler since then, now I have Fiddler v 4.4.3.0 beta)

it's worth mentioning that I need https decryption, so I need to get that working as well.

I don't have any filters applied. I can get the emulator to access the web, but then I have to go to the internet options and in LAN Settings uncheck the Proxy box and restart the emulator. So when Fiddler is working as Proxy I can't access the web (or my host).

What should I do? Can you help me, please?

Reply

Nico
Nico Belgium
3/27/2013 11:50:48 AM #

Hi Sofi,

it sounds like a problem with your Hyper-V network settings, try deleting all virtual switches in your Hyper-V manager and adding a new one.

Reply

Sofi
Sofi Sweden
3/28/2013 1:16:33 PM #

Hi,
I've tried to remove them and add it again.
But the one used is just a internal one, named "Windows Phone Emulator Internal Switch" is this correct?

Does it make any difference if Fiddler is running or not when I reopen the  emulator after adding the new virtual switch? (I think I've tried both though..)

Reply

Nico
Nico Belgium
3/30/2013 8:32:30 AM #

I just checked my settings in Hyper-V and the windows Phone emulator virtual machine has 2 network connections, one that connects to the internal switch like you mentioned and a second one that connects to my physical network card

Reply

Sofi
Sofi Sweden
4/3/2013 2:00:00 PM #

Hi, I've done some more testing and if I start the emulator when Fiddler isn't capturing. Then The emulator can reach the web. But if Fiddler is running then it can't.
I do have two virtual switches (one internal and one external). The external one seems to take over the settings from my Ethernet connection and this connection is instead set to Hyper-V Extensible virtual switch.

I have the opposite problem with my simulator for Windows store apps. This one doesn't connect when Fiddler isn't running (It seems as it doesn't care if Fiddler is started or not while starting it. ) So I have to have Fiddler capturing when debugging the windows store app.

Shouldn't they adapt to the network on startup?

Reply

Sofi
Sofi Sweden
4/3/2013 2:00:25 PM #

And also, Thank you for trying to help me Smile

Reply

Sofi
Sofi Sweden
4/3/2013 2:05:46 PM #

I just realized that the simulator can connect to webpage through the browser, just not through my application when Fiddler is off. But it reaches it from the application when Fiddler is on. Do you have any idea why?

Reply

Nico
Nico Belgium
4/4/2013 1:51:17 PM #

No idea, I haven't tried it with the Windows Store simulator. First thing that comes to mind is a problem with your firewall but that's a longshot. I'm running out of ideas Smile

Reply

Sofi
Sofi Sweden
4/12/2013 12:56:36 PM #

Thanks for your help, I finally got it working again. I had used the ComputerName when setting the prefs, but I needed to use the FullComputerName.

Reply

Nico
Nico Belgium
4/12/2013 1:10:39 PM #

awesome, thanks for letting me know the solution Smile

Reply

Erik K
Erik K United States
5/21/2013 6:07:28 PM #

Thank you Sofi, you and Google saved me some major headaches.

The *FULL* computer name should be specified in these howtos.

Reply

Pingbacks and trackbacks (2)+

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

  Log in

About the author

Hi,

My name is Nico, I’m an MCP living in Belgium.
I’m currently employed as a consultant in the Mobile Solution Center at RealDolmen, one of Belgium’s leading IT single source providers, where I focus on Windows Phone and Windows 8 development.

I'm also founding member and board member of the Belgian Metro App Developer Network, a user group focussed on Windows 8 and Windows Phone development. If you're in Belgium feel free to drop by if we're doing an event. http://www.madn.be

Since June 2012 I'm a proud member of Microsoft's Extended Experts Team Belgium. And in February 2013 I became a member of DZone's Most Valuable Bloggers family.

This blog will be about Windows Phone 7, C#, XNA , WPF, Silverlight, and much more!

I hope to get feedback from my readers either through comments, mail (nico_vermeir@hotmail.com), twitter, facebook, …

 

 

MeetLogo

 

MVBLogo

mybook

 

mybook

 

Month List