尝试使用其 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)