Connection Reset by Peer Java Exception

不羁岁月 提交于 2020-01-21 09:43:21

问题


URL uri = null;
    try
    {
        uri = new URL(aURL);
    }
    catch (MalformedURLException e)
    {
        // TODO Auto-generated catch block
        Log.e("My SOCKET CONNECTION ERROR 1-->>", e.toString());
        e.printStackTrace();
    }

    InetSocketAddress sa = InetSocketAddress.createUnresolved("XXX.XXX.X.XXX", 1080);
    Proxy proxy = new Proxy(Proxy.Type.SOCKS, sa);
    try
    {
        HttpURLConnection conn = (HttpURLConnection) uri.openConnection(proxy);
        conn.connect();
    }
    catch (IOException e)
    {
        // TODO Auto-generated catch block
        Log.e("My SOCKET CONNECTION ERROR 2-->>", e.toString());

        e.printStackTrace();
    }  

This is my code that i am trying to connect with SOCKS server with our IP but it gives me this error:

java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)

Why is this not connecting to server? Is there any mistake in my Code connecting to SOCKS server?

Thank you so much for your help!

来源:https://stackoverflow.com/questions/16996820/connection-reset-by-peer-java-exception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!