为什么 HttpEntity.toStrict 没有没有超时的变体?

Why HttpEntity.toStrict has no variant without a timeout?

Akka-http HttpEntity.toStrict 是一种消费实体的方式,当需要完整的 body 用于后续处理,但它没有没有超时参数的变体。

使用没有超时的 entity.dataBytes.runReduce(_ ++ _) 很容易消耗 body。但后果是什么?

问题 #1

如果HttpEntity.toStrict超时,akka-http会立即关闭连接吗?还是还在消耗 body 丢弃的数据?还是什么?

问题 #2

如果 body 在没有超时的情况下使用(如上面的代码),并且连接 "hangs",akka-http 配置中是否有任何适用的超时参数?为客户?为服务器?如果在启动 body 之前连接 "hangs",是否有适用的超时参数?

问题 #3

如果没有全局超时,为什么HttpEntity.discardBytes没有类似的超时参数?

If HttpEntity.toStrict times out, does akka-http close the connection immediately? Or still consuming the body discarding the data? Or what?

它会关闭 AFAIR 连接,因为它被视为失败并向下传播(以及取消)。

If a body is consumed without a timeout (like with the above code), and the connection "hangs", are there any applicable timeout parameters in akka-http configuration? For client? For server? If connection "hangs" before starting the body, are there any applicable timeout parameters?

文档中有关于超时的完整部分:http://doc.akka.io/docs/akka-http/current/scala/http/common/timeouts.html 这些包括在连接 "hang".

时触发的空闲超时

If there is no global timeout, why HttpEntity.discardBytes does not have a similar timeout parameter?

存在全局安全超时,最显着的是请求超时和空闲超时。所有记录在文档中。 http://doc.akka.io/docs/akka-http/current/scala/http/common/timeouts.html

当您根本不关心实体时,

discardBytes 真的很方便。我想我们可以添加一个带有超时的过载,但老实说,这是第一次有人要求它。无论如何,您都可以使用 Akka Streams 超时阶段轻松添加超时。