Is it possible that the server has closed the connection while we are still 
writing to the connection, and since there is no response from the server 
for a while, we hit the idle timeout exception?

Here is the code:

val source = Source
  .queue[(HttpRequest, Promise[HttpResponse])](overflowBufferSize, 
OverflowStrategy.dropNew)
  .via(Http().cachedHostConnectionPool[Promise[HttpResponse]](host, port))
  .toMat(Sink.foreach {
    case ((Success(resp), p)) => p.success(resp)
    case ((Failure(e), p)) => p.failure(e)
  })(Keep.left)
  .run

val promise = Promise[HttpResponse]
source.offer(httpRequest -> promise).flatMap {
  case QueueOfferResult.Enqueued => promise.future
  case other =>
    val message = s"queue failed due to $other"
    Future.failed(new RuntimeException(message))
}.recoverWith {
  case NonFatal(e) =>
    Future.failed(new RuntimeException(e.getMessage, e))
}

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to