Akka remoting between different version - scala

I was trying to use remoting between different akka versions. I have an application running akka 2.2.1 on scala 2.10.2 and an application running akka 2.0.5 on scala 2.9.2. The second app uses a library which is not available for scala 2.10.2, so I cannot simply update the app, neither downgrade the other one. I get a message error saying that the message was not delivered.
To test it, I created a dummy 2.2.1 akka application sending a String to a 2.0.5 akka actor which prints it to the console. To avoid the missing sender, the 2.2.1 app sends a message to an actor which routes it to an actor in the other version.
Are there any known compatibility issues between the two versions?
I already took care of conf files, changing netty and stuff, so it should only be a matter of versions. The dummy apps works fine if they have the same akka versions.
I can provide the error logs if you need them.

The remote communication protocol of Akka is not (yet) compatible between versions, meaning that what you observe is intentional. We need to wait at least one more major release before we can start stabilizing and then freeze the protocol to allow future interoperability. We recommend decoupling components using REST APIs for now and using remoting only where lockstep updates are possible.

Related

java.lang.NoSuchMethodError: org.jboss.netty.handler.codec.http.HttpRequest.setHeader(Ljava/lang/String;Ljava/lang/Object;)V

I had written a library and published it as a jar. Other applications used my library and everything was great.
Now the other application upgraded their dependencies. and now when they run. the application crashes when it calls my library. It seems that the application now depends on netty 4.1.8 whereas my library depended on a third party library which used an older version. Now when building the other application, sbt evicts my netty version with the newer one. The newer netty version does not have the method on which my code depends upon.
Thus the exception
org.jboss.netty.handler.codec.http.HttpRequest.setHeader(Ljava/lang/String;Ljava/lang/Object;)V"
com.ning.http.client.providers.netty.NettyAsyncHttpProvider.construct(NettyAsyncHttpProvider.java:693)
com.ning.http.client.providers.netty.NettyAsyncHttpProvider.buildRequest(NettyAsyncHttpProvider.java:650)
com.ning.http.client.providers.netty.NettyConnectListener$Builder.build(NettyConnectListener.java:144)
com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1070)
com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:935)
com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:499)
dispatch.HttpExecutor$class.apply(execution.scala:47)
dispatch.Http.apply(execution.scala:12)
dispatch.HttpExecutor$class.apply(execution.scala:42)
dispatch.Http.apply(execution.scala:12)
scalaxb.DispatchHttpClients$DispatchHttpClient$class.request(httpclients_dispatch.scala:21)
scalaxb.DispatchHttpClients$$anon$1.request(httpclients_dispatch.scala:6)
scalaxb.SoapClients$SoapClient$class.soapRequest(soap12.scala:41)
scalaxb.SoapClients$$anon$1.soapRequest(soap12.scala:23) scalaxb.SoapClients$SoapClient$class.requestResponse(soap12.scala:60)
scalaxb.SoapClients$$anon$1.requestResponse(soap12.scala:23)
I am already using the latest version of the 3rd party library (scalaxb) which depends on old netty.
This is really killing because my library is holding back the entire upgrade process of the application.
There isn't much you can do about this, aside from telling that application's maintainers that using your library requires that specific version of netty, and is not compatible with newer versions. They have to either downgrade back or replace you library with something else.

How to send HTTP 2.0 request in play framework(scala)

Backend running under play framework(v. 2.6.5 scala) must communicate with Apple Push Notificaton Service (APNs) . APNs requires using HTTP/2, and so i tried to find any way to implement such communication, but to my surprise i didn`t find any http scala clients, supporting http v 2.0.
Is there any way to realize such communication without going out of the framework?
Thanks!
Play Framework with a version prior to 2.6 does not support HTTP 2.0, but, Play Framework 2.6 is based on Akka-Http and has experimental support for HTTP 2.0. This feature is labeled "experimental" because the API may change in the future, and it has not been thoroughly tested in the wild.
To add support for HTTP/2, add the PlayAkkaHttp2Support plugin. You can do this in an enablePlugins:
lazy val root = (project in file("."))
.enablePlugins(PlayScala, PlayAkkaHttp2Support)
If you consider alternatives take a look at:
Jetty has a capability to use HTTP 2.0
Netty also supports HTTP 2.0
Check this list of known implementations of HTTP 2.0.
In Akka HTTP, which underlies Play! Framework, HTTP/2 support is experimental on the server side and not yet available on the client side, as far as I can tell. Work is in progress and is tracked on Github. Unless you're inclined to write HTTP/2 client support yourself and optionally donate it to the project (which would probably be a very satisfying experience), going outside of the framework is probably going to be a necessity for now, I'm afraid.
If you're in a position to use Java 9 (hey, it's been gold for two days!), you might consider its HTTP/2 client.
Vert.x is originally a Java framework inspired by NodeJS, but in its current incarnation it includes an HTTP/2 client with a Scala API: http://vertx.io/docs/vertx-web-client/scala/ - I've never used it in production so YMMV...
Edit: you might also consider sttp with the OkHttp backend, which supports HTTP/2.

Integrating Play Framework 2.6 with gRPC and Netty

At the time I write this post, Play Framework is at v2.6.0-M4. The v2.5 version of the framework had difficulties to work with gRPC because of Netty conflicts (see this stackoverflow answer).
I'm starting to look into gRPC and protobufs. Already ported a project from Play Framework 2.5 > 2.6.0-M4 in anticipation of the actual release. Currently I have some questions regarding integration of gRPC. I'm wondering how to let the gRPC server work along nicely with Play Framework. I know that v2.6 switched to Akka HTTP server instead of Netty, while I use the grpc-netty dependency in sbt so maybe I'll have to switch the project to Netty again (here's how).
For testing purposes, I created a quick and dirty GrpcServer.scala class that starts up a thread with the GrpcServer listening. I managed to add ScalaPB with gRPC and generate/compile my protobufs. It works perfectly to communicate with a small testing NodeJS app but I have to startup this server app independently from the main project:
private def start(): Unit = {
server = ServerBuilder.forPort(GrpcServer.port).addService(GreeterGrpc.bindService(new GreeterImpl, executionContext)).build.start
GrpcServer.logger.info("Server started, listening on " + GrpcServer.port)
sys.addShutdownHook {
System.err.println("*** shutting down gRPC server")
self.stop()
System.err.println("*** server shut down")
}
}
Possible solutions to integrate gRPC in Play Framework
Now for the real integration in Play Framework v2.6, I'm looking for suggestions. Here's some things I can do:
Create a module and start the gRPC server when Play Framework starts up, like described in this stackoverflow answer. This would mean that we run the gRPC server on a different port next to the existing server (Akka HTTP server from Play Framework 2.6)
Create a Scala Command and make it long-running. So we always make sure we start a command that runs the gRPC server when we start our application on a server.
Switch from Akka HTTP to Netty in Play Framework v2.6 and tightly integrate gRPC with the existing Netty server so it hooks into the existing Netty server instead of creating a server on our own. I would like this solution but not sure how to deal with it. It certainly would avoid having two separate http stacks running.
Any tips/ideas for a clean integration are helpful as there's not much information about Play Framework and gRPC available, except that there were issues in the previous 2.5 version...

Upgrade to webSocket message in play web sockets using scala

I am new to play framework and implementing web sockets using iteratees in Scala but when I run in browser it prints upgrade to Web sockets required with no compiler error. I have attached my snippet here. Please help. Am using Ubuntu platform.

Is akka-http fully compatible with spray-routing dsl?

Is akka-http fully compatible with spray-routing DSL? (my service is fully implemented in spray-routing trying to understand how seamless is migration (hopefully just dependency changing)
Is it production ready?
Can it run on tomcat like spray has Servlet30ConnectorServlet
Is there an example of how to run akka-http on tomcat container with similar Servlet30ConnectorServlet
No see https://www.linkedin.com/grp/post/746917-5967985951106945028
Not of this date yet the only package exist is akka-http-experimental but it appears it should be there soon.
No
Only by using tomcat as a simple start/stop for the akka-http service