My application embeds a local http server that can be accessed through the loopback device at URL: http://127.0.0.1:8080/
It works fine with WiFi enabled, it also works fine with no external network (no WiFi, no 3G) but it fails when WiFi is disabled and 3G enabled.
Connecting through adb shell and executing "netcfg" I can see that the loopback device is always enabled:
shell@android:/ $ netcfg
...
lo UP 127.0.0.1/8 0x00000049 00:00:00:00:00:00
...
Alos "ping 127.0.0.1" continues to work while switching on/off the WiFi or 3G.
Any idea?
UPDATE: Adding to the puzzle. From my dev computer I forward the tcp port:
$ adb forward tcp:8080 tcp:8080
Then I try to connect from my PC using http://127.0.0.1:8080/. It works, but when it continues to fail when using a browser running on the android device.
UPDATE 2015-06-01: When working on 3G I see on adb logcat lot of related errors similar to:
W/ContextImpl( 504): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendStickyBroadcast:1239 com.android.server.TelephonyRegistry$3.onReceive:818 android.app.LoadedApk$ReceiverDispatcher$Args.run:788 android.os.Handler.handleCallback:725 android.os.Handler.dispatchMessage:92
and
E/CellLocation( 8336): create GsmCellLocation
It doesn't make any sense to me to trigger Gsm activity to connect to the loopback device.
UPDATE 2015-06-01 (2): I managed to install wget in /data/data/com.XXXX.yyy/files/appFiles/bin
Then I connect through "adb shell" -> "run-as com.XXXX.yyy" and finally execute: wget -O - "http://127.0.0.1:8080/"
I works properly so I can discard any weird security setup that disables loopback access on localhost, so I guess it has something to do with WebView/WebViewClient trying to wrongly use a 3G external proxy to access the loopback. Now I'm wondering whether it's possible to disable the proxy on WebView.
Finally it looks it was a problem with the WebView trying to access an external proxy even for the lookback interface. I fixed the issue following the solution proposed at: WebView android proxy
User contributions licensed under CC BY-SA 3.0