Hi,

I'm trying to get akka-http client to pipeline HTTP requests in one TCP 
connection. I rewrote what was based on Http().singleRequest into this:

(path("batch-geocode") & put & entity(as[Map[String, String]])) { br =>
  val connectionPool = Http().cachedHostConnectionPool[String]("geocoder.ca")
  val requests = br.mapValues(GeocodeRequest).toList.map(_.swap)
  val ftrRs: Future[List[(String, StandardResponse)]] = Source(requests)
    .via(connectionPool)
    .mapAsync(4){ case (tryResponse, id) =>
      Future.fromTry(tryResponse)
        .flatMap(transformResponse).recover{
          case t: Throwable => ErrorResponse(None, t.getMessage)
        }
        .map(id -> _)
    }.runFold(List[(String, StandardResponse)]())((a,b) => b :: a)

  onSuccess(ftrRs){ case rs =>
    complete(OK -> rs.toMap)
  }
}

(In case you were wondering, I have a JSON codec that knows how to work 
with scala Maps.)

my config has

akka.http.host-connection-pool {
  max-connections = 2
  pipelining-limit = 4
}


Wireshark consistently shows two TCP connections established one by one 
(initiating SYN packets are adjacent in the log). However, if I set 
max-connections to 1, akka-http actually sends two HTTP requests at once, 
but after the first response is received, it immediately sends FIN, ACK to 
the server and then opens another TCP connection and sends the second 
request again to receive a response. Am I missing something?

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to