Unmarshaller not working for HttpEntity for text/html response for "Error in stage [unknown-operation]: Promise already completed"

43 views
Skip to first unread message

Sarah Yin

unread,
Aug 16, 2016, 2:04:43 AM8/16/16
to Akka User List
Hi Akka User,

I've been trying to Unmarshall HttpResponse and decode it as a String. However All the method I've searched failed in "Error in stage [unknown-operation]: Promise already completed"

Has anyone come to this before? Thanks in ad!

Here are the Future I want to decode 
val responseFuture: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = uri))
 

Here are some of the methods I've tried:

responseFuture onComplete {
case Success(response) =>
val timeout = 300.millis
response.status match {
case StatusCodes.OK =>
println("printing content")
// println(response.entity.dataBytes.runForeach(println))
// println(response.entity.dataBytes.map(_.utf8String))
// response.entity.dataBytes
// .map(line => println(line))
// println(response.entity.toStrict(5 seconds).map(_.data.decodeString("UTF-8")))
// println(Unmarshal(response.entity).to[String])
// val entity = Unmarshal(response.entity).to[String]
// entity onComplete { entity =>
// println(entity)
// }
// Unmarshaller.entityToString(response.entity)
// println(PredefinedFromEntityUnmarshallers.stringUnmarshaller(response.entity))
// println(response.entity.toStrict(5 seconds).map(_.data.decodeString("UTF-8")) )
val bs: Future[ByteString] = response.entity.toStrict(timeout).map { _.data }
// val s: Future[String] = bs.map(_.utf8String)
println(bs)
case _ =>
println("failed to get dynamic url")
}
case Failure(error) =>
println(error.toString)
}


 

Konrad Malawski

unread,
Aug 28, 2016, 6:44:33 PM8/28/16
to Akka User List
What Akka version are you on?

We have a similar issue reported but in a slightly different place... https://github.com/akka/akka/issues/19981

What is the server responding with specifically?
I'd be very suprised if on a normal usual response we fail toStricting() this is used by all tools, including some at Lightbend so that would have come up already hm..


--
>>>>>>>>>> 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 akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--
Cheers,
Konrad 'ktoso' Malawski
Reply all
Reply to author
Forward
0 new messages