scala - Akka 块大小异常
问题描述
我正在尝试使用以下代码从 Akka 发出单个请求:
val request = HttpRequest(
method = HttpMethods.GET,
uri = "url"
)
val responseFuture: Future[HttpResponse] = Http().singleRequest(request)
val entityFuture: Future[HttpEntity.Strict] = responseFuture.flatMap(response => response.entity.toStrict(2.seconds))
entityFuture.map(entity => entity.data.utf8String)
但是,当我请求一个大的 json 字符串时,我得到以下异常。
akka.http.scaladsl.model.EntityStreamException: HTTP chunk size exceeds the configured limit of 1048576 bytes
我如何配置这个,我没有使用 Akka typed(我认为),只是这个:
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
import system.dispatcher
解决方案
您可以使用以下配置来增加请求大小:
akka.http.parsing.max-chunk-size = 16m
推荐阅读
- python - 电子邮件地址中的特殊字符名称存在问题
- face-recognition - face_recognition 错误:列表索引超出范围
- android - 为什么电容器将所有内容都保存到 IndexedDB 而不是 Android 上的 sdcard 上?
- python - 从本地主机发送电子邮件时,有什么方法可以更改或隐藏我的设备 IP?
- php - 如何在 php 表单的查询中使用 nullif()
- c# - 安装我的应用程序后无法加载 dll 'SQLite.interop.dll'。该 dll 存在并且安装 Visual Studio 神秘地修复它
- javascript - 我想用相同的但使用reduce完成的替换这个forEach函数。你能说我哪里做错了吗?
- symfony - 如何在 symfony 中使用 api-platform 来编辑帖子数据?
- go - 如何配置 swagger UI 使其不需要 URL?
- tensorflow - 将 tensorflow 数据格式从 nhwc(通道在后)切换到 nchw(通道在前)时出现问题