But in the akka-http version I use (akka-http_2.13 v10.1.12) there isn’t a method called connectionTo() in the akka.http.javadsl.Http class. (Plus I don’t know why the official javadoc doesn’t include akka-http_2.13 so it’s super hard to find any documentation)
I’m trying to launch http2 requests because I’m stuck on this error after migrating from akka-http_2.11 to akka-http_2.13, and I’m guessing it might because the server I’m sending requests to default with http2:
[ERROR] [07/08/2021 05:58:57.732] [graph-api-akka.actor.default-dispatcher-19] [akka://graph-api/system/Materializers/StreamSupervisor-2/flow-6-0-PoolFlow] Error in stage [akka.http.impl.engine.client.OutgoingConnectionBlueprint$PrepareResponse@25f31b7]: The server-side HTTP version is not supported
akka.http.scaladsl.model.IllegalResponseException: The server-side HTTP version is not supported
at akka.http.impl.engine.client.OutgoingConnectionBlueprint$PrepareResponse$$anon$3.onPush(OutgoingConnectionBlueprint.scala:191)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:423)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:625)
...
And it is really painful for me to debug. The API server I’m requesting, Facebook Graph API, should support both http1.1 and http2. So I can’t figure out why I got The server-side HTTP version is not supported. Or is there anything I can do in my akka-http code to force the requests to be http1.1?
Thank you so much for your prompt reply, could you also hint me on how I should solve this error?
[ERROR] [07/09/2021 11:18:52.996] [graph-api-akka.actor.default-dispatcher-8] [akka://graph-api/system/Materializers/StreamSupervisor-2/flow-6-0-PoolFlow] Error in stage [akka.http.impl.engine.client.OutgoingConnectionBlueprint$PrepareResponse@64046ed6]: The server-side HTTP version is not supported
akka.http.scaladsl.model.IllegalResponseException: The server-side HTTP version is not supported
at akka.http.impl.engine.client.OutgoingConnectionBlueprint$PrepareResponse$$anon$3.onPush(OutgoingConnectionBlueprint.scala:191)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:541)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:423)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:625)
at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:502)
at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:600)
at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:769)
at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:784)
at akka.actor.Actor.aroundReceive(Actor.scala:537)
at akka.actor.Actor.aroundReceive$(Actor.scala:535)
at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:691)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:577)
at akka.actor.ActorCell.invoke(ActorCell.scala:547)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
at akka.dispatch.Mailbox.run(Mailbox.scala:231)
at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
at java.util.concurrent.ForkJoinTask.doExec$$$capture(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
I used packet sniffer and sent the exact same request using curl to the server, and the server can respond normally. So I think this might be Akka parsing problem. But it is really hard to trace how Akka parse the result and what caused the error.
This is the raw request: "User-Agent: akka-http/10.1.12" 'https://graph.facebook.com/v5.0/22092443056?fields=id&access_token=xyz&appsecret_proof=xyz'
You can set akka.http.client.log-unencrypted-network-bytes = 100 to see what’s actually sent and received. The error probably means that you are connecting against a server that doesn’t respond with a HTTP/1.1 response.
When Travis CI - Test and Deploy with Confidence has run through, you could also check with the latest snapshot which now includes an encoding of the first bytes of the received response in the error message.
Thank you so much @jrudolph
I’ve solved the “The server-side HTTP version is not supported” problem, turns out the root cause was that I need to use cachedHostConnectionPoolHttps to query https endpoint instead of cachedHostConnectionPool.