I want to redirect a websocket connection to another instance of play but haven't figured out how to do it yet.
Basically I have an akka cluster with load balancing between the nodes and actors (with akka routers), so far so good, it's working.
Because of this I need to receive a websocket connection in one instance of play, but i want to use the router (akka actor) to forward it to another instance of play. This is important because with this I achieve my load balancing requirement.
A tipical route that accepts websocket connections looks like this:
def socket = WebSocket.accept[JsValue, JsValue] { request =>
ActorFlow.actorRef(out => MyWebSocketActor.props(out))
}
The problem is that this immediately returns a Flow (akka streams) and establishes the websocket connection and i need to forward the request and established the connection in another instance of Play. This forwarding must go through the actors in order to maintain the load balancing. I can forward the messages just fine, but I need to forward the initial connection.
Any help is appreciated, thanks.