gpt4 book ai didi

amazon-s3 - AmazonS3 : Getting warning: S3AbortableInputStream:Not all bytes were read from the S3ObjectInputStream, 中止 HTTP 连接

转载 作者:行者123 更新时间:2023-12-04 00:46:25 40 4
gpt4 key购买 nike

这是我收到的警告:

S3AbortableInputStream:Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or drain the input stream after use.



我尝试将 try 与资源一起使用,但 S3ObjectInputStream 似乎没有通过此方法关闭。
 try (S3Object s3object = s3Client.getObject(new GetObjectRequest(bucket, key));
S3ObjectInputStream s3ObjectInputStream = s3object.getObjectContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectInputStream, StandardCharsets.UTF_8));
){
//some code here blah blah blah
}

我还尝试了下面的代码并明确关闭,但这也不起作用:
S3Object s3object = s3Client.getObject(new GetObjectRequest(bucket, key));
S3ObjectInputStream s3ObjectInputStream = s3object.getObjectContent();

try (BufferedReader reader = new BufferedReader(new InputStreamReader(s3ObjectInputStream, StandardCharsets.UTF_8));
){
//some code here blah blah
s3ObjectInputStream.close();
s3object.close();
}

任何帮助,将不胜感激。

PS:我只从 S3 读取文件的两行,并且文件有更多数据。

最佳答案

通过其他媒体得到了答案。在这里分享:

该警告表明您在未读取整个文件的情况下调用了 close()。这是有问题的,因为 S3 仍在尝试发送数据,而您正在使连接处于悲伤状态。

这里有两个选择:

  • 从输入流中读取其余数据,以便可以重用连接。
  • 调用 s3ObjectInputStream.abort() 关闭连接而不读取数据。该连接不会被重用,因此您在下一个重新创建连接的请求中会受到一些性能影响。如果读取文件的其余部分需要很长时间,这可能是值得的。
  • 关于amazon-s3 - AmazonS3 : Getting warning: S3AbortableInputStream:Not all bytes were read from the S3ObjectInputStream, 中止 HTTP 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45624175/

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