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.
Related
I'm using ionic 6 (with Angular). Is there a websocket client plugin?
I want to communicate with a websocket server written in c# but I can't find any plugins to use ionic as websocket client.
You don't need a dedicated ionic plugin if you just want to subscribe to a websocket. Existing angular websocket libraries should work.
I personally prefer using socket-io, which works perfectly fine: https://socket.io/
I suggest you to use the same websocket pattern on backend as the frontend. The socket.io doesn't communicate with others websockets, so it means you need to check first which WS actually you are using on backend to keep using the same on the mobile App.
Please give me an example on socket io connecting the server using java client and server. Describe socket io jar details also. I have googled but does not get the correct source code.
Socket.IO Server is not a Java implementation.
Consequentially you can not have a Java server.
You need to get some Java adaptation of Socket.IO, example:
Netty Socket.IO Java Implementation
Fortunately, Socket.IO has a Java client implementation you can use.
Socket.IO Java Client Implementation
Both links have examples and demo's.
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...
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.
There's a sample application that comes with Play Framework 2.0. The application uses Play's WebSocket implementation on the server side. I am wondering can I use socket.io on the client side to connect with Play's WebSocket implementation on the server side?
In theory, yes, you can make Socket.io connect to your websocket server wia the corresponding ws url.
In practice, I tried and I had some issues, so it might require you to adapt Socket.io for it to work properly. Granted I tried on 2.0.1 or similar, so it may be working currently with no issues.