Search code examples
playn

Is PlayN websocket implementation in Java supposed to be working?


According to the platform status, it should. I am trying to accomplish a basic Hello World proof of concept but I can't get my Java client connect to my server with PlayN. As soon as I call createWebSocket(), the onClose() gets called. However, I was able to connect to my server using a standard html page.

Client code:

    WebSocket s = PlayN.net().createWebSocket("ws://localhost:8080/test", new Net.WebSocket.Listener(){
    public void   onClose() {System.out.println("close");};       
    public void   onDataMessage(ByteBuffer msg) {System.out.println("data");};
    public void   onError(String reason) {System.out.println("error");};
    public void   onOpen() {System.out.println("open");};
    public void   onTextMessage(String msg) { System.out.println("text");};
    });

Solution

  • I finally found the problem. Version 1.4 of PlayN uses Draft10 dy default. I have updated my local copy of PlayN to use : http://mvnrepository.com/artifact/com.netiq/websocket and I changed the default Draft to Draft17 and it could connect to Tomcat.