gpt4 book ai didi

amazon-web-services - 尝试从 AWS Lambda 中的缓冲区读取器读取时出现 SocketTimeoutException

转载 作者:行者123 更新时间:2023-12-02 05:00:02 28 4
gpt4 key购买 nike

我有一个 AWS lambda 应用程序尝试读取 csv 文件。它将文件读取为:

S3Object s3Object = S3Client.getObject(new GetObjectRequest(SrcBucketName,SrcKey));

使用以下命令逐行读取文件:

final InputStreamReader isr = new InputStreamReader(s3Object.getContent());
final BufferedReader br = new BufferedReader(isr);
try{
aList = br.lines().skip(1)
.map(processLines)
.collect(toList());
} catch (Exception e) {

} finally {
isr.close();
br.close();
}

AWS Lambda 引发间歇性套接字超时问题。完整的堆栈跟踪是:

   Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:593)
at sun.security.ssl.InputRecord.read(InputRecord.java:532)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
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 com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:72)
at com.amazonaws.event.ProgressInputStream.read(ProgressInputStream.java:180)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:72)
at com.amazonaws.services.s3.internal.S3AbortableInputStream.read(S3AbortableInputStream.java:115)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:72)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:72)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:72)
at com.amazonaws.event.ProgressInputStream.read(ProgressInputStream.java:180)
at java.security.DigestInputStream.read(DigestInputStream.java:161)
at com.amazonaws.services.s3.internal.DigestValidationInputStream.read(DigestValidationInputStream.java:59)
at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:72)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.readLine(BufferedReader.java:324)
at java.io.BufferedReader.readLine(BufferedReader.java:389)

文件大小仅为 61 KB。是SDK的问题吗?你能告诉我这里出了什么问题吗?

提前致谢。

最佳答案

尝试以下操作:

    S3Object amazonS3Client.getObject(new GetObjectRequest(bucketName, filePath));
ArrayList<String> fileContent = new ArrayList<String>();

InputStream is = s3Object.getObjectContent;
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
Try {
String line;
while ((line=reader.readLine()) != null) {
fileContent.add(line);
}
} Catch (IOException e) {
e.printStackTrace();
} finally{
reader.close();
is.close();
}

关于amazon-web-services - 尝试从 AWS Lambda 中的缓冲区读取器读取时出现 SocketTimeoutException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46096428/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com