Im using the websocket4j library and I looked at an example on how to use it in server applications. I took the code from there and imeplemented it into my current project which was using raw sockets before. No matter which client I use , I seem to be getting An IOExcpetion saying that the handshake has failed. I have no clue whats wrong cause I took code from the example server ( which is obviously supposed to work ) , and I used a javascript example client to make sure that its not the client's fault. Heres the main method.
 public static void main(String args[]){
        BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("PORT ( default - 1000 ): ");
        int port=1000;
        try{
            port=Integer.parseInt(b.readLine());
        }
        catch(Exception e){
            System.out.println("Wrong format. Using 1000 instead");
            port=1000;
        }
        System.out.println("Server Started. Waiting for connections");
        try{
            WebServerSocket listener=new WebServerSocket(port);
            while(true){
                WebSocket server=listener.accept();
                U413ChatServer connection=new U413ChatServer(server);
                Thread t=new Thread(connection); 
                t.start();
            }
        }
        catch(Exception e){ e.printStackTrace();
        }
    }
And heres what comes on screen
Server Started. Waiting for connections
java.io.IOException: Handshake failed
        at websocket4j.AbstractWebSocket.<init>(Unknown Source)
        at websocket4j.server.WebSocket.<init>(Unknown Source)
        at websocket4j.server.WebServerSocket.accept(Unknown Source)
        at U413ChatServer.main(U413ChatServer.java:55)
Caused by: java.io.IOException: Unexpected header field: Sec-WebSocket-Key: yfOg
xCbblVyY8ARVFyMtOw==
        at websocket4j.server.WebSocket.handshake(Unknown Source)
        at websocket4j.AbstractWebSocket$HandshakeRunner.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.lang.Thread.run(Thread.java:722)
Line 55 is:
WebSocket server=listener.accept();
Any help would be really appreciated