How WebSocket Works
In a WebSocket configuration, Integration Server can act as a WebSocket server or a WebSocket client. When Integration Server acts as a WebSocket server, it hosts a server endpoint that you create using Designer. The server endpoint captures the properties required for callback services for the life cycle of a WebSocket. The endpoint is identified by a path within a server.
When Integration Server acts as a WebSocket client it creates a WebSocket client endpoint. The client endpoint captures information related to connection and the respective callback services thereof. It also connects to the WebSocket server identified by a URI.
The following diagram illustrates how a request is handled in a WebSocket configuration:
(1). To establish a WebSocket session between a client and a Integration Server, the client needs to send an HTTP Upgrade request. This is done using pub.client:websocketservice.
(2). If Integration Server is capable and willing to upgrade the session, it sends a HTTP 101 response to the requesting client. At this point the handshake is considered successful and the connection between the server and the client is upgraded to the WebSocket protocol. This is done using a capable WebSocket port.
(3). Data can now flow bidirectional between the Integration Server and the client over the WebSocket session. This is done using pub.websocket:send service.
(4). Any client or server in the data exchange can request the WebSocket connection be closed by sending a close request. This is done using pub.websocket:close service.