java - IOException : javax.net.ssl.SSLHandshakeException : SSL handshake aborted: ssl=0xafdb8e00: I/O error during system call, 连接由对等方重置

标签 java android ssl httpsurlconnection

嘿,我有一个 http 请求,今天它工作正常,但我收到了一个错误

 IOException : javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0xafdb8e00: I/O error during system call, Connection reset by peer

我就是这样处理请求的,效果很好

   try {
        Url = new URL(url);
        urlConnection = (HttpURLConnection) Url.openConnection();
        urlConnection.setRequestMethod("POST");
        urlConnection.setUseCaches(false);
        urlConnection.setConnectTimeout(30000);
        urlConnection.setReadTimeout(30000);
        urlConnection.setRequestProperty("Content-Type", "text/xml");
        urlConnection.setRequestProperty("Host", "host");


        String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n" +
                " <soap:Body> \n" +
              xml data
                " </soap:Body> \n" +
                " </soap:Envelope>";

        System.out.println("the body is " + body);

        byte[] outputInBytes = body.getBytes("UTF-8");

        OutputStream os = urlConnection.getOutputStream();

        os.write(outputInBytes);

        //System.out.println("Message = " + urlConnection.getResponseMessage());

        System.out.println(" * 3");

        //urlConnection.connect();

        if (urlConnection.getResponseCode() == 200) {
            InputStream in = new BufferedInputStream(urlConnection.getInputStream());
            result = IOUtils.toString(in, "UTF-8");
            System.out.println("Salik Success is" + result);

            os.close();

            return result;
        } else {
            InputStream in = new BufferedInputStream(urlConnection.getErrorStream());
            result = IOUtils.toString(in, "UTF-8");
            System.out.println("Failure is" + result);


            os.close();

            return null;
        }


    } catch (MalformedURLException e) {
        //e.printStackTrace();
        result = "error";
        System.out.println("MalformedURLException = " + e.toString());
    } catch (IOException e) {
        //e.printStackTrace();
        result = "error";
        System.out.println("IOException" + e.toString());
    } finally {
        urlConnection.disconnect();
    }

有什么帮助吗? 问候

最佳答案

当互联网连接缓慢或您的应用程序无法连接到服务器时会发生此异常。

关于java - IOException : javax.net.ssl.SSLHandshakeException : SSL handshake aborted: ssl=0xafdb8e00: I/O error during system call, 连接由对等方重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35463477/

相关文章:

java - 错误[Ljava.lang.Object;将 X509Certificate 的数组列表转换为数组时,无法转换为 [Ljava.security.cert.X509Certificate

java - 警告 : The (sub)resource method contains empty path annotation

java - 如何在静态函数中使用模板?

PHP 显示图像(SSL 代理)

perl - 错误 : 500 Can't connect to foo. com:443(未知错误错误:140773F2:SSL 例程:SSL23_GET_SERVER_HELLO:sslv3)

amazon-web-services - 尝试从 AWS Lambda 但不是桌面访问 AWS Device Farm 时出现 SSL 证书错误

java - 限制 View 滚动上的 OnBindViewHolder

Android 在顶部和底部 ListView 上设置淡入淡出的 alpha 渐变,如 instagram 实时聊天

android - getLoaderManager().initLoader(...,...,...) 的 args 参数的用途?

android - ListView 中的 onItemClickListener 不适用于 Android 中的 TabActivity