I have been trying to integrate akka-grpc in our apps to facilitate communication between play and akka app.
I am successfully able to host services on grpc server in our akka app.
The client will be running on Play (v2.7.M3). Now this is where I am little confused. Since grpc requires http2 as per doc, do I need to enable http2 in my play app even if I just plan to use client there. No grpc based services will be hosted here. If enabling http2 is required for play app to run client, can I enable only for grpc client and still have rest of my app run on http1.1.
No, you don’t need to enable HTTP/2 for the play server to use the Akka gRPC client. (The client is currently Netty based so it is in fact not using the Akka HTTP infrastructure at all yet)
Thanks for response. Good to know that I don’t have to enable http/2 for play.
I followed the steps as per document to generate client for Play. But it throws below exception when I run the client. Not sure what I am missing.
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[IllegalArgumentException: Could not find Jetty NPN/ALPN or Conscrypt as installed JDK providers]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:274)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:194)
at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:347)
at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:345)
at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:414)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
Caused by: java.lang.IllegalArgumentException: Could not find Jetty NPN/ALPN or Conscrypt as installed JDK providers
at io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:186)
at akka.grpc.internal.NettyClientUtils$.nettyHttp2SslContext(NettyClientUtils.scala:81)
at akka.grpc.internal.NettyClientUtils$.$anonfun$createChannel$3(NettyClientUtils.scala:49)
at scala.Option.map(Option.scala:146)
at akka.grpc.internal.NettyClientUtils$.$anonfun$createChannel$1(NettyClientUtils.scala:49)
at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:304)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
akka.grpc.client {
"helloworld.GreeterService" {
host = "127.0.0.1"
port = 8085 //this is where grpc service is hosted
}
}
play.modules.enabled += "com.company.grpc.AkkaGrpcClientModule"
Interesting. I think I have seen this error before when testing the combination of Akka gRPC, Play and Gradle, but shelved it since Gradle does not ship with Play 2.7 support itself yet anyway (https://github.com/gradle/gradle/issues/6362). I don’t think I have seen it with sbt before.
How are you starting your application? From sbt? With which command?
I finally figured out. Since I m working on non-tls based grpc service, I have to disable tls explicitly in conf. This is not documented anywhere until I checked reference.conf.
akka.grpc.client {
"helloworld.GreeterService" {
host = "127.0.0.1"
port = 8085 //this is where grpc service is hosted
use-tls = false //by default it is true
}
}
I also removed ALPN agent from build.sbt & plugins.sbt since I don’t intend to host grpc service in play.
Yeah it was not that obvious when following example for Play client. May be add section and/or example showiong what needs to be done tls and non-tls solution.