This microservice allows sending and receiving messages via WebSocket protocol
The main configuration is done by changing following properties:
- uri - connection URI
- frameType - outgoing WebSocket frame type, can be either
TEXTorBINARY(TEXTby default) - sessionAlias - session alias for incoming/outgoing th2 messages (e.g.
ws_api) - handlerSettings - WebSocket event handler settings
- grpcStartControl - enables start/stop control via gRPC service (
falseby default) - autoStart - start service automatically (
trueby default and ifstartControlisfalse) - autoStopAfter - stop after N seconds if the service was started automatically prior to send (
0by default which means disabled)
Service will also automatically connect prior to message send if it wasn't connected
Event handler can be configured by changing following properties in the handlerSettings block of the main configuration:
- pingInterval - interval for sending ping-messages in ms (
30000by default) - defaultHeaders - map of headers and their values to add to the HTTP handshake request (the map is empty by default)
uri: wss://echo.websocket.org
frameType: TEXT
sessionAlias: api_session
startControl: true
autoStart: true
handlerSettings:
pingInterval: 30000
defaultHeaders:
HeaderA:
- value1
- value2
HeaderB:
- value3- input queue with
subscribeandsendattributes for outgoing messages - output queue with
publish,first(for incoming messages) orsecond(for outgoing messages) attributes - (optional) output queue with
publish,eventattributes for outgoing events
This section describes the messages received and produced by the service
This service receives messages that will be sent via MQ as MessageGroups, containing a single RawMessage with a message body
Incoming and outgoing messages are sent via MQ as MessageGroups, containing a single RawMessage with a message body.
This section describes the events that can be produced by the service. You can use that information to trigger some actions on certain events.
When the service is connected it will publish the event with
name=Connected to: <url>
and type=Info
When the service is disconnected for some reason it will publish the event with
name=Disconnected from: <uri> - statusCode: <statusCode>, reason: <reason>
and type=Info
Here's an example of infra-mgr config required to deploy this service
apiVersion: th2.exactpro.com/v1
kind: Th2Box
metadata:
name: ws-client
spec:
image-name: ghcr.io/th2-net/th2-conn-ws-client
image-version: 0.3.1
custom-config:
uri: wss://echo.websocket.org
sessionAlias: api_session
grpcStartControl: true
autoStart: true
autoStopAfter: 300
handlerSettings:
pingInterval: 30000
type: th2-conn
pins:
- name: to_send
connection-type: mq
attributes:
- subscribe
- send
- raw
- name: outgoing_messages
connection-type: mq
attributes:
- publish
- second
- raw
- name: incoming_messages
connection-type: mq
attributes:
- publish
- first
- raw
# Optional pin for sending the events from the service to another box
# - name: service_events
# connection-type: mq
# attributes:
# - publish
# - event- common lib update from 3.25.1 to 3.40.0
- bom lib update from 3.0.0 to 3.1.0
- opportunity to add query params to uri from handler
- reconnect if handling of event fails
- ability to stop client during reconnect loop
- The common version is updated from 3.13.4 to 3.25.1
- Events are published to all pins that match the requested attributes
- running-flag wasn't reset if connection has failed during start
- cancel ping timer in case of close/error WS events
- deadlock when trying to send a message from
IHandler.onOpen
- a new
preOpenmethod that allows the handler to adjust some client's settings DefaultHandlerhas the parameter to specify default headers for HTTP handshake
- inverted
autoStartsetting behavior - reconnect loop during socket availability check
- ability to start/stop via gRPC service
- auto-start/stop feature
- high idle CPU usage