0

I'm doing an HttpPost from my android AVD as follows...

// Create a new HttpClient and Post Header 
HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httppost = new HttpPost("http://www.yoursite.com/api/GETTrafficDirector"); 
HttpResponse response = null; 

try { 
    // Add your data 
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 
    nameValuePairs.add(new BasicNameValuePair("id", "12345")); 
    nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!")); 
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 

    // Execute HTTP Post Request 
    response = httpclient.execute(httppost); 
}

I'm running Fiddler when the post executes but nothing happens in Fiddler. Shouldn't Fiddler catch this post? I was hoping to inspect the Entity contents since the display in Eclipse is so hard to read. Thanks, Gary

Doug Porter
  • 7,721
  • 4
  • 40
  • 55
Dean Blakely
  • 3,535
  • 11
  • 51
  • 83

1 Answers1

0

If you look at this tutorial you have to start the Android AVD using a proxy pointing to 127.0.0.1 and whatever port fiddler is running on.

EDIT: After some experimentation using these instructions and it occurred to me that maybe the emulator started respecting 127.0.0.1 as itself and not the host computer so I entered my hosts IP address

Then removed the single character from each of username and password in the APN and fiddler started logging traffic from the emulator's browser but not from my app.

So that at least is part way there.

FURTHER EDIT:

Looking at this question Getting information about the system proxy it appears that you need to explicitly tell your app to use the System Proxy settings (which seems mental to me)

AND YET ONE MORE EDIT:

If I add

    HttpHost proxy = new HttpHost("192.168.0.9", 8888);
    client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

to my client set-up in my app I then see the outgoing traffic from my app

Community
  • 1
  • 1
Paul D'Ambra
  • 7,629
  • 3
  • 51
  • 96
  • That solution doesn't work anymore (read the comments). Also see http://stackoverflow.com/questions/6936230/android-emulator-error2011-08-02-111401-emulator-panic-could-not-open-c. Still havent found a solution that will work. – Dean Blakely Oct 02 '12 at 17:08
  • Hmm, Fiddler link here http://aurir.wordpress.com/2010/03/22/tutorial-getting-android-emulator-working-with-fiddler-http-proxy-tool/ but even that seems to have comments that suggest it might not work after 2.2... – Paul D'Ambra Oct 02 '12 at 17:49
  • I've just tried that on my machine with Fiddler 2 and a 2.3 emulator and I can't capture traffic from my app either. In fact... my emulator can't get to the internet at all with the settings as in my last comment – Paul D'Ambra Oct 02 '12 at 18:06
  • I tried your code but it doesn't work. See my new post at http://stackoverflow.com/questions/12699461/continuing-problems-with-avd-and-fiddler. – Dean Blakely Oct 02 '12 at 22:41