I follow the instructions in the official documentation of the Play Framework 2.5.x for Java Websockets, I created a controller with this function
public static LegacyWebSocket<String> socket() {
return WebSocket.withActor(MyWebSocketActor::props);
}
And the Actor class MyWebSocketActor:
public class MyWebSocketActor extends UntypedActor {
public static Props props(ActorRef out) {
return Props.create(MyWebSocketActor.class, out);
}
private final ActorRef out;
public MyWebSocketActor(ActorRef out) {
this.out = out;
}
public void onReceive(Object message) throws Exception {
if (message instanceof String) {
out.tell("I received your message: " + message, self());
}
}
}
Then the application is launched. I am trying to connect to ws: // localhost: 9000, as written in the official documentation:
Tip. You can check your WebSocket controller at https://www.websocket.org/echo.html . Just set the location to WS: // local :. 9000
But the web socket seems unreachable, how can I check it?
thank
source
share