I have a simple websocket application which I have deployed on
tomcat 7.0.52. I am using JSR 356 API javax.websocket-api-1.0-b08.jar.
My
Java server side code is
import javax.websocket.server.ServerEndpoint;
import javax.websocket.*;
@ServerEndpoint("/hello")
public class HelloBean {
@OnMessage
public
String sayHello(String name)
{
return name + "return";
}
}
Whenever i try to connect to websocket it throws me error that its close.
On Client end (javascript) : Code is as follows
var ws = new WebSocket("ws://localhost:8080/hello");
ws.onopen = function()
{
ws.send("Message to send");
};
ws.onmessage = function (evt)
{ // var received_msg = evt.data;
alert("Message is received...");
};
ws.onclose = function()
{
// websocket is closed.
alert("Connection is closed...");
};
I am not able to understand why it is showing connection is closed message.
Help on this will be much appreciated.
Thanks
NP