How to debug http calls on Android devices?

I am writing a Lovefilm client for Android, and it is not so bad if I do not have problems with remote calls to retrieve data from the API.

Does anyone have any tips on debugging remote calls like this? Can I tcpdump on Android or is there my own way to do this?

For example, I use the Scribe-java library for OAuth to access the Lovefilm API, I can authenticate the search and retrieval of the movie list in the user account when the device is working with Gingerbread, but trying to retrieve the accessToken on Froyo causes an empty response and an explicit response code of -1 , I would like to see what is happening under them.

Another example that I would like to use for raw http for is trying to start a search, I get an IOError, which says: "The request for authentication is zero"

+4
source share
5 answers

I used Fiddler (http-proxy to debug http calls) using the Android emulator in these cases. Just start the proxy server and run the emulator with the correct proxy server address (-http-proxy).

+3
source

Fiddler is the most useful option. On @Scythe emulator the answer will work, but on a real device you will need to install a proxy server in Apache Http Client. The following code will do this:

HttpHost proxy = new HttpHost("youripaddr", 8888); params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); 

If you use https, fiddler is not so useful. In this case, you can enable build support in the Apache Http Client. The following code does this:

Headers only:

 java.util.logging.Logger apacheHeaderLog = java.util.logging.Logger.getLogger("org.apache.http.headers"); apacheHeaderLog.setLevel(java.util.logging.Level.FINEST); 

Headers and wire:

 java.util.logging.Logger apacheWireLog = java.util.logging.Logger.getLogger("org.apache.http.wire"); apacheWireLog.setLevel(java.util.logging.Level.FINEST); 

Please note that for this you will need to configure java.util.logging Handler at the highest level, and the default handler is configured to write to the logcat log, which by default will filter DEBUG entries (the best).

+3
source

If your system can exchange a wifi connection, you should be able to route packets from any device through your system, and then using wirehark you can control your calls or receive tcpdump.

Also, and more importantly, it would be better if you recorded your network calls and answers, as suggested by @Matthew

Windows 7 Wi-Fi Sharing: http://www.winsupersite.com/article/faqtip/windows-7-tip-of-the-week-use-wireless-hosted-networking-to-share-an-internet- connection-wirelessly.aspx

+1
source

Since I always encounter similar problems and it seems that many people having the same problems over and over again, I wrote a quick tutorial to debug client-server using netcat and cURL .

This, of course, only works in the simplified case, when you always "fake" on the connection side.

You can use tools like tcpdump or Wireshark to eavesdrop. Which will definitely be easier if you can run the server instance directly on the local machine.

0
source

Stetho is a great tool for FB that helps debug Android applications. You can access local data and check your network using this.

http://facebook.imtqy.com/stetho/

0
source

Source: https://habr.com/ru/post/1342552/


All Articles