Hi,

Has anyone created a SOCKS network client on Android?  Namely, I'm trying 
to simply open a network connection to an HTTP server through a Dante SOCKS 
server (from Ubuntu Server 12.04.3 LTS), set up to allow connection without 
any authentication.  SOCKS server is verify to work by using Firefox.

Then, I ran the following snippet on Android and then on Desktop Java:

(PROXY_ADDR and PROXY_PORT are the proxy address and port that Dante runs 
on, connected through WiFi)

             URL url = new URL("http://www.android.com:80/";);
             Proxy proxy = new Proxy(Proxy.Type.SOCKS, 
InetSocketAddress.createUnresolved(PROXY_ADDR, PROXY_PORT));
             HttpURLConnection urlConn = (HttpURLConnection) 
url.openConnection(proxy);
             urlConn.connect();
             urlConn.getResponseCode();

These 5 lines works and gives me a 200 OK when run on Java 1.6 on my 
Desktop, however the same code runs on a Galaxy Nexus (Android 4.3) results 
in Dante log showing "socks protocol error" and then Dante disconnects the 
client.  This is the logcat output:

09-04 16:46:13.886 D/PROXY_TEST(28685): java.net.SocketException: recvfrom 
failed: ECONNRESET (Connection reset by peer)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:545)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.io.IoBridge.recvfrom(IoBridge.java:509)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
java.io.InputStream.read(InputStream.java:163)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
java.io.BufferedInputStream.read(BufferedInputStream.java:227)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.io.Streams.readAsciiLine(Streams.java:201)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:579)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.net.http.HttpEngine.readResponse(HttpEngine.java:827)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
com.example.ProxyTestActivity$1.javaNetTestExplicitProxy(ProxyTestActivity.java:164)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
com.example.ProxyTestActivity$1.run(ProxyTestActivity.java:185)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
java.lang.Thread.run(Thread.java:841)
09-04 16:46:13.886 D/PROXY_TEST(28685): Caused by: 
libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by 
peer)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.io.Posix.recvfromBytes(Native Method)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.io.Posix.recvfrom(Posix.java:140)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
09-04 16:46:13.886 D/PROXY_TEST(28685):     at 
libcore.io.IoBridge.recvfrom(IoBridge.java:506)
09-04 16:46:13.886 D/PROXY_TEST(28685):     ... 14 more

Has anyone run into anything similar?

Thanks in advance!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to