I need to be able to insert a proxy between my application and the HTTP server that it communicates with. The HTTP server is running on another machine on the LAN. The proxy is running on the same machine as the emulator.
I am using android-10, and am experiencing these same problems on Ubuntu and Windows 7.
If I start the emulator like this:
emulator.exe @default
Then the application will connect fine.
However, If I start the application like this:
emulator.exe @default -http-proxy 127.0.0.1:8008
Requests made from the internet browser (to Google) will go through the proxy, but the application cannot make a connection.
I have tried setting the proxy settings in the APN, along with using the LAN IP address of my local machine.
The application IS using HTTP (http://developer.android.com/reference/java/net/HttpURLConnection.html), so the proxy should be able to interpret the request.
I can access the server through the internet browser within the emulator with the proxy off, but not with the proxy on.
I ran the emulator with the following line:
emulator.exe @default -http-proxy 127.0.0.1:8008 -debug-proxy
and noticed that requests were going out as:
http_service_connect: trying to connect to 192.168.3.131:8080
http_service_connect: using HTTP rewriter
tcp:192.168.3.131:8080(35): connecting
tcp:192.168.3.131:8080(35): connected to http proxy, sending header
tcp:192.168.3.131:8080(35): sending 39 bytes:
>> 43 4f 4e 4e 45 43 54 20 31 39 32 2e 31 36 38 2e CONNECT 192.168.
>> 33 2e 31 33 31 3a 38 30 38 30 20 48 54 54 50 2f 3.131:8080 HTTP/
>> 31 2e 31 0d 0a 0d 0a 1.1....
tcp:192.168.3.131:8080(35): header sent, receiving first answer line
tcp:192.168.3.131:8080(35): received 'HTTP/1.0 200 Connection established'
tcp:192.168.3.131:8080(35): receiving second answer line
tcp:192.168.3.131:8080(35): received ''
tcp:192.168.3.131:8080(35): connection succeeded
But no GET or POST request ever makes it to the proxy.
Any recommendations on how to continue troubleshooting this issue?
In case anyone comes looking, here is how I solved this issue:
I set the application to talk directly to the proxy:
Then, I configured the proxy to forward all of these requests to the server:
Not the prettiest solution, but it works fine for a test environment.