3

尝试使用其 Java SDK 从阿里云的对象存储服务 (OSS) 消费数据时出现“SSL 对等体错误关闭”异常。我们正在使用 Oracle Java 8.x、Hadoop 3.x。我们在将其作为 Oozie 工作流运行并将数据保存到 HDFS 路径时遇到此异常。如何解决这个问题?

Gradle 依赖:compile(group:'com.aliyun.oss',name:'aliyun-sdk-oss',version:"2.8.3")

 // Create an OSSClient instance.
    ClientBuilderConfiguration clientConfig = new ClientBuilderConfiguration();
    clientConfig.setProxyHost(PROXY_HOST);
    clientConfig.setProxyPort(PROXY_PORT);
    clientConfig.setProtocol(Protocol.HTTPS);

    OSS ossClient = new OSSClientBuilder().build(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET, clientConfig);
    String fileKey = "4868a87eb2a0f7a06c43";
    OSSObject ossObject = ossClient.getObject(BUCKET_NAME, fileKey);
    InputStream objectContent = ossObject.getObjectContent();

    try (InputStream inputStream = objectContent) {
        copyInputStreamToFile(inputStream, targetFile);
    }

例外:

Failing Oozie Launcher, Main class [org.apache.oozie.action.hadoop.JavaMain], main() threw exception, javax.net.ssl.SSLException: SSL peer shut down incorrectly
org.apache.oozie.action.hadoop.JavaMainException: javax.net.ssl.SSLException: SSL peer shut down incorrectly
...
Caused by: javax.net.ssl.SSLException: SSL peer shut down incorrectly
    at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:596)
    at sun.security.ssl.InputRecord.read(InputRecord.java:532)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:933)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
    at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
    at org.apache.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:200)
    at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)
    at java.util.zip.CheckedInputStream.read(CheckedInputStream.java:82)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at com.aliyun.oss.event.ProgressInputStream.read(ProgressInputStream.java:116)
    at java.util.zip.CheckedInputStream.read(CheckedInputStream.java:82)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:100)
    at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:68)
    at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:129)
4

1 回答 1

2

你每次都随机或一致地遇到这个问题?您没有为人们提供足够的信息来帮助您。到目前为止,您尝试过哪些解决方案?

此错误消息SSL peer shut down incorrectly是一般消息,可能由多种原因引起。我建议您通读此书一一尝试。

尝试检查远程 SSL 证书,验证其有效性,很可能问题就在那里。

您也可以打开它-Djavax.net.debug=ssl,handshake,然后提供握手日志,这有助于缩小根本原因。

更新:

打开-Djavax.net.debug=ssl,handshake需要您对握手过程有一定程度的了解,这在一段时间内可能会很困难。您可以使用mitmproxy等工具来检查 https 流量。

您还可以使用在线 TLS 检查器来检查 TLS 支持。

于 2020-09-30T10:37:02.720 回答