WebSocket Client Service

The WebSocket Client service is a component of the Cloud Gateway. It enables applications to establish a WebSocket connection with a WebSocket server endpoint.

Example Use Cases

The WebSocket Client Service supports the following use cases:
  • A service attempts to connect to a WebSocket endpoint to send and receive data. The component first gets an instance of the client container, which implements the WebSocketContainer interface through a dependency injection. The service then calls a connectToServer() method and passes a ClientEndpoint-annotated WebSocket class to the method.
  • A service attempts to connect to a WebSocket endpoint to transfer/receive data. The component first gets an instance of the client container, which implements the WebSocketContainer interface through dependency injection. It then calls a connectToServer() method and passes a ClientEndpoint-annotated WebSocket object instance to the method. This method allows the consumer to register a WebSocket ClientEndpoint with a configured state as opposed to an uninstantiated class.

SSL Context

The WebSocket Client uses the global SSLContext to enable WebSockets over TLS. After being configured, the client automatically establishes a TLS connection when connecting to a WSS URI.

Dependencies

Maven dependencies and an OSGI import package are required to consume the service.
  • The following Maven dependency is required:
    <dependency>
        <groupId>javax.websocket</groupId>
        <artifactId>javax.websocket-api</artifactId>
        <version>1.0</version>
    </dependency>
  • The following OSGi import is required to consume the bundle:
    Import-Package: javax.websocket;version="[1.0,2)"