Hi Harit, you need to consume response entity data stream. You either do it by attaching a Sink.cancelled to response.entity.dataBytes or using an Unmarshaller to unmarshal response to your chosen data structure.
On Thu, Aug 27, 2015 at 2:31 AM, Harit Himanshu < [email protected]> wrote: > Hello Community, > > I am writing my first akka-http client and facing this issue. > > Requirements? > > 1. Every 10 seconds Akka Actor gets a message that it needs to deliver > to server. That code looks like > > case ecMonitorInformation: ECMonitorInformation => > httpPost("/ec/monitor", > httpEntityFromJson(ecMonitorInformation.toJson)) > > def httpEntityFromJson(jsonValue: JsValue): Strict = { > HttpEntity(MediaTypes.`application/json`, ByteString(jsonValue > toString)) > } > > > > First I tried the following code > > def post(endpoint: String, entity: Strict) = { > Http().singleRequest(HttpRequest(uri = Notifier.notificationUrl + > endpoint, method = HttpMethods.POST, > entity = entity)) onComplete { > case Success(response) => response match { > case HttpResponse(StatusCodes.OK, _, _, _) => > log.info("communicated successfully with Skyhigh") > } > case Failure(response) => > log.error("communicated failed with Skyhigh: {}", response) > } > } > > and after 5 successful requests, nothing happens for a while and then I > see > > ERROR c.s.e.notification.Notifier - communicated failed with Server: > java.lang.RuntimeException: Exceeded configured max-open-requests value of > [32] > > > > I asked this question on StackOverflow > <http://stackoverflow.com/questions/32233486/akka-http-exceeded-configured-max-open-requests-value-of-32>, > and based on the response I tried to set up a Connection-Pool on host level > and here are the changes I made > > At Actor-level I did > > val poolClientFlow = Http().cachedHostConnectionPool[Unit](host = > "localhost", port = 8080) > > Then I did > > def post(endpoint: String, entity: Strict) { > val responseFuture: Future[(Try[HttpResponse], Unit)] = > Source.single(HttpRequest(uri = endpoint, method = HttpMethods.POST, > entity = entity) ->()) > .via(poolClientFlow) > .runWith(Sink.head) > > responseFuture.onComplete { > case Success((triedHttpResponse, _)) => triedHttpResponse match { > case Success(response) => log.info("communicated successfully > with Server: {}", response) > case Failure(error) => log.error("communication failed with > Server: {}", error) > } > case Failure(error) => > log.error("communicated failed with Server: {}", error) > } > } > > But again, I face this issue again > > ERROR c.s.e.notification.Notifier - communication failed with Server: > java.lang.RuntimeException: Exceeded configured max-open-requests value of > [32] > > What am I doing wrong? > > Thanks for the help in advance > > > > > -- > >>>>>>>>>> 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. > -- Martynas Mickevičius Typesafe <http://typesafe.com/> – Reactive <http://www.reactivemanifesto.org/> Apps on the JVM -- >>>>>>>>>> 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.
