1

i am using janus gateway its route is working fine when i hit from the browser

http://192.168.1.4:8088/janus/info

but the code is throwing exception here is my code

val responseFuture: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = "http://192.168.1.4:8088/janus/info"))
    
  responseFuture
      .onComplete {
        case Success(res) => println("we got http response" + res)
          log.info("get session id response " + Unmarshal(res).to[String])
          val strJson = Unmarshal(res).to[String]
        case Failure(e: Exception) => log.error("something wrong", e)
      }
  }

and here are the exception i am getting

[info] Running janusgateway.rest.GetStartedWithJanus 
18:13:21.169 734 [default-akka.actor.default-dispatcher-4] Slf4jLogger INFO - Slf4jLogger started
we got http responseHttpResponse(200 OK,List(Connection: Keep-Alive, Access-Control-Max-Age: 86400, Access-Control-Allow-Origin: *, Date: Wed, 02 Sep 2020 13:13:22 GMT),HttpEntity.Chunked(application/json),HttpProtocol(HTTP/1.1))
18:13:22.451 2016 [default-akka.actor.default-dispatcher-5] GetStartedWithJanus$ INFO - get session id response Future(<not completed>)
java.lang.IllegalStateException: Substream Source cannot be materialized more than once
    at akka.stream.impl.fusing.SubSource$$anon$13.setCB(StreamOfStreams.scala:792)
    at akka.stream.impl.fusing.SubSource$$anon$13.preStart(StreamOfStreams.scala:802)
    at akka.stream.impl.fusing.GraphInterpreter.init(GraphInterpreter.scala:306)
    at akka.stream.impl.fusing.GraphInterpreterShell.init(ActorGraphInterpreter.scala:593)
    at akka.stream.impl.fusing.ActorGraphInterpreter.tryInit(ActorGraphInterpreter.scala:701)
    at akka.stream.impl.fusing.ActorGraphInterpreter.preStart(ActorGraphInterpreter.scala:750)
    at akka.actor.Actor.aroundPreStart(Actor.scala:545)
    at akka.actor.Actor.aroundPreStart$(Actor.scala:545)
    at akka.stream.impl.fusing.ActorGraphInterpreter.aroundPreStart(ActorGraphInterpreter.scala:690)
    at akka.actor.ActorCell.create(ActorCell.scala:637)
    at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:509)
    at akka.actor.ActorCell.systemInvoke(ActorCell.scala:531)
    at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:294)
    at akka.dispatch.Mailbox.run(Mailbox.scala:229)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:242)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

i have deploted janus on my local machine and i am a beginer in it the above exception seems like janus is not responding to the request

swaheed
  • 3,671
  • 10
  • 42
  • 103
  • 1
    `Unmarshal(res).to[String]` gives you a `Future[String]`. Perhaps there is a limitation that you can only unmarshal a response once? If that's the case, I would have `val strJsonFut: Future[String] = Unmarshal(res).to[String]` and then do `strJsonFut.foreach { strJson => log.info(s"get session ID response $strJson"); // Do anything else with strJson that makes sense }` – Levi Ramsey Sep 04 '20 at 15:38

0 Answers0