Can Fiddler capture traffic to localhost on an Android emulator?

1 Answer 2771 Views
Android Fiddler Classic Fiddler Everywhere Mobile
Tony
Top achievements
Rank 1
Tony asked on 31 Jan 2022, 05:16 PM

I am trying to capture traffic using Fiddler from an Android app running on an emulator (I am using MuMu).  I got most of what I was trying to accomplish. I added the required cert to Android and I can see most http/https traffic fine.

 

The issue I am facing is that I cannot see requests from the app that go to http://127.0.0.1:26284. I understand that the localhost for the Android emulator is different than my machine which is running Fiddler. I did some searching and found info on Android networking (https://developer.android.com/studio/run/emulator-networking) and 10.0.0.2 but I am not sure how to use that info or if it is even relevant to my issue.

 

For what I do have working, I set the proxy in the emulator to my actual machine's address (the one running Fiddler) and set it to bypass the proxy for 127.0.0.1 (otherwise the app wouldn't work as the calls to localhost would fail).

 

My goal is to be able to see the request/responses on the emulators localhost. Is it possible via Fiddler?  Maybe adding some redirects or something like that, just so I can see the request/response? Or any other way at all? I do not have access to change the calls in the app that go to 127.0.0.1.

 

Please let me know if there is any additional info that I can give that may help. This is my first time working with emulators and proxies.

1 Answer, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 02 Feb 2022, 09:27 AM

Hello Tony,

 


Indeed, the Android loopback address is usually 10.0.2.2 (this is the address for the "state" emulators, but it might be different if you use a third-party emulator). To direct the localhost request from the mobile device to go through the Fiddler proxy and via verse, you need to create a rule in Fiddler that will make the Fiddler proxy act as a reverse proxy. Here is how you could achieve that for both Fiddler Classic and Fiddler Everywhere:


Fiddler Classic:

- Create a rule that will redirect the mobile localhost address with port 8888 (address is something like 10.0.2.2 or 10.0.0.2 depending on the emulators) to the localhost address (on the Fiddler host). In your case, that would look something like this:

// Inside the OnBeforeRequest handler*, add a new line of code:

if (oSession.host.toLowerCase() == "10.0.2.2:8888") oSession.host = "localhost:26284";

- Activate the rule, enable capturing and execute the request to http://10.0.2.2:8888 in your mobile browser

 

Fiddler Everywhere:

- Create a rule that will redirect the mobile localhost address with port 8866 (address is something like 10.0.2.2 or 10.0.0.2 depending on the emulators) to the localhost address (on the Fiddler host). In your case, that would look something like the one shown in the screenshot:

- Activate the rule, enable capturing and execute the request to http://10.0.2.2:8866 in your mobile browser

 

 

Regards,
Nick Iliev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Android Fiddler Classic Fiddler Everywhere Mobile
Asked by
Tony
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Share this question
or