Tomcat 8 javax.websockets not working

I have tomcat 8-RC1 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 accurately display the structure of the 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 slowdown, I also included the following:

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

so ServerEndPoint indicates how to access websocket, the question is what do I need to install in web.xml? while the web socket is still unavailable.

I am trying to define ServConnect as a regular servlet in web.xml, but this does not work. this is just the time when I try to access a ServConnect location.

what configuration am i missing for this ServConnect web class class to work?

+4
source share
1 answer

The WebSocket specification states that you must annotate a specific class. ServConnect will be considered as a WebSocket endpoint, but will not receive any events, since annotations on the interface are ignored.

I would suggest getting your own version of the Echo example, and then expand from there.

+1
source

Source: https://habr.com/ru/post/1500537/


All Articles