Akka-http HttpEntity.toStrict
is a way to consume an entity when the full body is required for later processing, but it does not have a variant without a timeout parameter.
It is quite easy to consume a body with entity.dataBytes.runReduce(_ ++ _)
which does not have a timeout. But what are the consequences?
Question #1
If HttpEntity.toStrict
times out, does akka-http close the connection immediately? Or still consuming the body discarding the data? Or what?
Question #2
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?
Question #3
If there is no global timeout, why HttpEntity.discardBytes
does not have a similar timeout parameter?
If HttpEntity.toStrict times out, does akka-http close the connection immediately? Or still consuming the body discarding the data? Or what?
It'd close the connection AFAIR, since it's counted as a failure which propagates down the stream (as well as up as a cancellation).
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?
There's a full section about timeouts in the documentation: http://doc.akka.io/docs/akka-http/current/scala/http/common/timeouts.html These include idle-timeouts which would trigger when connections "hang".
If there is no global timeout, why HttpEntity.discardBytes does not have a similar timeout parameter?
There are global safety timeouts, most notably request timeouts and idle timeouts. All documented in the docs. http://doc.akka.io/docs/akka-http/current/scala/http/common/timeouts.html
discardBytes
is really just convenience when you don't care at all about the entity. I guess we could add an overload with a timeout, it's the first time anyone asked for it to be honest though. You can easily add timeouts using the Akka Streams timeout stages anyway.