从 S3 下载文件时抛出 Akka Stream 异常 [英] Akka Stream Exception Thrown When Downloading File From S3

查看:35
本文介绍了从 S3 下载文件时抛出 Akka Stream 异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码从 S3 下载文件:

I am trying to download a file from S3 using the following code:

     wsClient
      .url(url)
      .withMethod("GET")
      .withHttpHeaders(my_headers: _*)
      .withRequestTimeout(timeout)
      .stream()
          .map {             
            case AhcWSResponse(underlying) =>
                  underlying.bodyAsBytes
              }

运行时出现以下异常:

    akka.stream.StreamLimitReachedException: limit of 13 reached

这是因为我在使用 bodyAsBytes 吗?这个错误是什么意思 ?我还看到此警告消息,可能与此相关:

Is this because I am using bodyAsBytes? What does this error mean ? I also see this warning message which is probably related:

 blockingToByteString is a blocking and unsafe operation!

推荐答案

发生这种情况是因为如果使用 stream(),则需要使用 bodyAsSource 来使用源.这样做很重要,否则会对连接产生背压.bodybodyAsBytes 已实现并且确实消耗了源代码,但由于某种原因,实现者决定让您知道您应该使用 execute()而不是 stream(),将正文限制为 13 个字节字符串和 50 毫秒超时.

This happens because if you use stream(), you need to consume the source using bodyAsSource. It is important to do so or it would otherwise backpressure the connection. body or bodyAsBytes are implemented and do consume the source but for some reason the implementor decided to let you know that you should have used execute() instead of stream() by limiting the body to 13 ByteStrings and 50ms timeout.

这篇关于从 S3 下载文件时抛出 Akka Stream 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆