Sending and receiving messages with the WebSocketClient

The WebSocketClient contains similar functionality to the standalone HttpClient component.
Prerequisites: The httpClient palette is open. HttpClientService has been added to station’s Service container. Standalone client types in the HttpClientService have been enabled.
A regular conversation within the HTTP protocol consists of multiple requests and responses sent over separate underlying connections. A WebSocket is a persistent connection to an endpoint allowing full-duplex communications, where either the client or server side may send a message at any time.

Perform the following steps:
  1. Drag a WebsocketClient component from the palette to the station and double-click the component.
    You may put it in the Drivers container.
    The component’s AX Property Sheet opens.
  2. Expand Address.
    The Address properties open.
    Image
  3. Expand Request Body.
    The Request Body properties open.
    Image
  4. Populate the Data slot of the Request Body.
    Notice that like the HttpClient’s other source types are available here.
  5. Right-click the WebsocketClient and click Actions > Send.
    The driver attempts to connect to the WebSocket and transmit the message. This example echos back all messages received.
    Image

    With the Payload Send Policy set to PollAndCov, any changes to the source message automatically result in a new message send:

    Image
  6. Expand Health.
    The properties open.
    Image

    The Health component contains the same properties as the regular HttpClient, however the response code should only ever show the value of the initial upgrade request, which initiated the WebSocket connection.

    The driver sends a regular keep-alive ping message while the connection is active.

  7. To disconnect from the WebSocket, right-click the component and click Actions > Disconnect.