Skip to end of metadata
Go to start of metadata

WSO2 AS 5.3.0 supports WebSocket 1.1 API as defined by the JSR-356 specification. This is provided by Apache Tomcat, which is embedded in AS. You can run the following sample web application to see how WebSockets work in AS.

Note that you do not need additional configurations on AS server-level to enable Websocket support for web applications.

Running the sample

The "Example" sample is deployed in AS by default. You can run this sample as explained below.

  1. Start WSO2 Application Server.

  2. Log in to the management console and click List under Applications to open the Running Applications page.

  3. The "example" sample will be listed as a web application. Click Go to URL to open the web application. Alternatively, you can directly point your browser to the URL of this sample, which is http://localhost:9763/example/. Note that the port number in the URL needs to be updated if you have set a port offset for the server in the <AS_HOME>/repository/conf/carbon.xml file.

  4. When you open the URL, click Websocket examples. The following samples will be listed:

    1. Echo example: This sample echoes whatever the message you send to the server via websocket. There are several websocket endpoints listed here to illustrate three different mechanisms that implement websocket services.

      • programmatic API - Invoking a Websocket endpoint that is registered programmatically. This is the interface-driven approach where the developer implements the javax.websocket.Endpoint interface to create the service.

      • annotation API (basic) - Invoking a websocket service that is defined using java annotations. This is the annotation-driven approach where the developer interacts with the websocket lifecycle events via annotated POJOs.

      • annotation API (stream) - This also follows the annotation-driven approach, and the messages sent from the server are streamed.

    1. Chat example: This simulates a standard chat application. In this application, the messages received are broadcast to all the users that are connected to this websocket service.
    2. Multiplayer snake example
    3. Multiplayer drawboard example
  • No labels