Question

I have tomcat 8-RC1 installed in order to use javax.websockets to write websocket based applications.

there are examples at http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/ that show exactly the structure of a websocket class so I implemented the following interface:

public interface XpoWebSocket {

@OnOpen
public void onOpen(Session session);

@OnClose
public void onClose();

@OnMessage
public void onTextMessage(String message);

public Session getSession();

}

in the line above the class deceleration I also included the following:

@ServerEndpoint(value = "/ServConnect")
public class ServConnect implements XpoWebSocket {
...

so the ServerEndPoint is to point how to access to websocket, the question is what do i need to set in web.xml ? for now the web socket is still not accessible.

I try to define ServConnect as a regular Servlet in web.xml but that doesn't work. it just time out when I try to access the ServConnect location.

what configuration am I missing to let this ServConnect websocket class work ?

Was it helpful?

Solution

The WebSocket spec says that you have to annotate the concrete class. ServConnect will be treated as a WebSocket endpoint but will not receive any events as the annotations on the interface are ignored.

I'd suggest getting your own version of the Echo example working and then expanding from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top