DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Debugging Android Web Traffic

Debugging Android Web Traffic

Eric Daugherty user avatar by
Eric Daugherty
·
Feb. 25, 12 · Java Zone · Interview
Like (0)
Save
Tweet
8.26K Views

Join the DZone community and get the full member experience.

Join For Free

Normally, I would use a packet sniffer, such as WireShark (OS X and Windows) to look at the network traffic and debug the application.

However, for Android development I do my primary development on a physical Android device.  It is faster, and provides a more realistic experience during development and debugging.  However, since the network traffic is no longer going through my computer, WireShark doesn't help.

To solve this, I use another program called Charles.  Charles is a 'Web Debugging Proxy Application'.  In short, it is a tool similar to WireShark, that allows you to easily debug network traffic.  Charles is a bit 'higher level' than WireShark, and provides a simpler view of the web requests to developers.

It also has a great feature, called Reverse Proxy.  This allows you to setup your local computer as a proxy for web traffic.  You can set it up as follows:


If your normal Web Service host was targetwebserver.com:80, you would set it up like the image above.  You can then change your mobile application configuration to point at the IP address of your computer, using port 64829 (or whatever you set it to).

Note: Make sure your mobile devices is on the same WiFi network as your computer!

Now, all traffic will be routed through your local machine, and Charles will capture all the traffic, allowing you to debug your network communications.

Charles also supports HTTPS proxies, so you can use it even if the web services are over HTTPS (as they probably should be).

Of course, this also works fine for iOS, although I find myself using the simulator more in iOS, which allows WireShark or normal Charles to work fine.

Charles is commercial software, but I've found it to be worth the price.  I believe you could probably setup a reverse proxy on your computer using many different approaches (you could always run your own Apache), which would enable you to use the free WireShark application as well.

Does anyone have other approaches?

UPDATE:
And an intrepid reader (tehnoir) points out that you can also just use Charles as a 'normal' Proxy server, and then configure your device to use your computer as a proxy server, which will then proxy all traffic through.  This allows you to sniff traffic without changing anything in your application (great for testing).

It would seem that simple Port Forwarding (another Charles feature) may also work as well.

 

From http://blog.ericdaugherty.com/2012/02/debugging-android-web-traffic.html

Web Service Android (robot)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • API Security Tools: What To Look For
  • Spring, IoC Containers, and Static Code: Design Principles
  • On Architects, Architecture, and Failures
  • Major PostgreSQL Features You Should Know About

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo