The following sample contains a server definition which supports WebSockets using a default configuration setting for HTTP transport and webcontainer.
These WebSocket samples show how to set up WebSocket Endpoints using annotations or programmatically. These samples exercise opening, reading from, writing to, and closing a WebSocket connection. Also shown is the use of encoders, decoders, the PathParam annotation, and Pong message processing.
This sample can be installed onto runtime versions 2013.11.0.0 (V8.5.5.Next Alpha) and later.
To run the WebsocketApp application:
- Extract the sample into the Liberty installation by running the command below from the root of your server installation:
java -jar WebsocketSample.jar
- Start the WebsocketSample server by running the command below from the
bindirectory in the Liberty profile installation:
server run WebsocketSample
- Confirm the application started by looking for the following message in the log:
CWWKZ0001I: Application WebsocketApp started in XX.XX seconds.
- In your browser, enter the URL for the application: http://localhost:9136/WebsocketApp/index.html (where port 9136 assumes the httpEndpoint provided in the sample server.xml has not been modified).
- In your browser choose a link and following the instructions to exercise a WebSocket sample.
WebsocketApp.war file contains the source and binaries for the application, and can be used to import it to Eclipse.
The application is automatically installed because it is located in the server dropins directory. Any number of applications can be installed from this location.