1 秒后未订阅 Akka HTTP 错误响应实体
Akka HTTP Error Response entity was not subscribed after 1 second
我正在使用 Akka HTTP cachedHostConnectionPoolHttps 池作为 Akka Streams Flow 的一部分发送请求:
private val requestFlow: Flow[(HttpRequest, HelperClass), Either[Error, String], _] =
Http().cachedHostConnectionPoolHttps(BaseUrl).mapAsync(1) {
case (Success(HttpResponse(_, _, entity, _)), _) =>
Unmarshal(entity).to[String].map(response => {
Right(response)
})
case (Failure(ex), _) =>
Future(Left(Error(ex)))
}
由于某种原因,并未处理所有请求响应。一些错误结果:
a.h.i.e.c.PoolGateway - [0 (WaitingForResponseEntitySubscription)] Response entity was not subscribed after 1 second. Make sure to read the response entity body or call `discardBytes()` on it.
如何在保持以上流量的情况下订阅我的回复?
如文档中所建议,通过以下方式实现实体处理可解决问题:
private val requestFlow: Flow[(HttpRequest, HelperClass), Either[Error, String], _] =
Http().cachedHostConnectionPoolHttps(BaseUrl).mapAsync(1) {
case (Success(HttpResponse(_, _, entity, _)), _) =>
entity.dataBytes
.runReduce(_ ++ _)
.map(r => Right(r.toString))
case (Failure(ex), _) =>
Future(Left(Error(ex)))
}
虽然这不是最好的解决方案,但您可以像这样增加响应订阅超时:
akka.http.host-connection-pool.response-entity-subscription-timeout = 10.seconds
我正在使用 Akka HTTP cachedHostConnectionPoolHttps 池作为 Akka Streams Flow 的一部分发送请求:
private val requestFlow: Flow[(HttpRequest, HelperClass), Either[Error, String], _] =
Http().cachedHostConnectionPoolHttps(BaseUrl).mapAsync(1) {
case (Success(HttpResponse(_, _, entity, _)), _) =>
Unmarshal(entity).to[String].map(response => {
Right(response)
})
case (Failure(ex), _) =>
Future(Left(Error(ex)))
}
由于某种原因,并未处理所有请求响应。一些错误结果:
a.h.i.e.c.PoolGateway - [0 (WaitingForResponseEntitySubscription)] Response entity was not subscribed after 1 second. Make sure to read the response entity body or call `discardBytes()` on it.
如何在保持以上流量的情况下订阅我的回复?
如文档中所建议,通过以下方式实现实体处理可解决问题:
private val requestFlow: Flow[(HttpRequest, HelperClass), Either[Error, String], _] =
Http().cachedHostConnectionPoolHttps(BaseUrl).mapAsync(1) {
case (Success(HttpResponse(_, _, entity, _)), _) =>
entity.dataBytes
.runReduce(_ ++ _)
.map(r => Right(r.toString))
case (Failure(ex), _) =>
Future(Left(Error(ex)))
}
虽然这不是最好的解决方案,但您可以像这样增加响应订阅超时:
akka.http.host-connection-pool.response-entity-subscription-timeout = 10.seconds