Appearance
Web socket client
Connects to a remote WebSocket server, sends every input record as a message and emits every message received from the server. One connection per component, kept open while the flow runs.
Pins
| Pin | Kind | Types | Description |
|---|---|---|---|
| Input | input | Viaducta.Plugins.Http.Types.WebSocketMessage, Viaducta.Plugins.TextPlugin.Types.TextRecord | Message to send. Connects first if needed. |
| Output | output | Viaducta.Plugins.Http.Types.WebSocketMessage | Called for every message received from the server. |
| Start | start | Opens the connection. Called by the system at flow start when unconnected. | |
| OnConnect | on connect | Viaducta.Plugins.Http.Types.WebSocketMessage | Called (with an empty message) after each successful (re)connect, e.g. to send a subscribe message. |
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
Uri | string | Server URL, ws://host:port/path or wss://.... | |
AuthType | dropdown: 0 None, 1 Basic, 2 Digest, 3 NTLM, 4 Bearer, 5 Jwt, 6 OAuth1, 7 OAuth2, 8 Other, 9 ClientCertificate | 0 | Authentication of the opening HTTP handshake. |
Domain | string | Windows domain (AuthType 3). | |
Username | string | User name (AuthType 1, 2, 3). | |
Password | password | Password (AuthType 1, 2, 3). | |
Bearer | string | Written as-is into the Authorization header (AuthType 4, 5, 7), so include the scheme: Bearer eyJ.... | |
ConsumerKey | string | OAuth 1.0a consumer key (AuthType 6), signed as GET on Uri. | |
ConsumerSecret | string | OAuth 1.0a consumer secret (AuthType 6). | |
AccessToken | string | OAuth 1.0a access token (AuthType 6). | |
TokenSecret | string | OAuth 1.0a token secret (AuthType 6). | |
Authorization | string | Complete Authorization header value (AuthType 8). | |
ClientCertificate | certificate | Name of a certificate object in the repository (AuthType 9). | |
MaxMessageSize | integer | 1048576 | Max size of a received message in bytes. |
IgnoreCertificate | boolean | false | Broken, see Notes. Leave false. |
Headers | dictionary (JSON object) | Headers for the opening handshake only, e.g. {"X-Client":"viaducta"}. | |
TimeOutMs | integer | 30000 | Ignored. |
Behaviour
- The connection is opened on
Startor on the first input. If it is closed (by the server or a network error), the next input orStartcall reconnects; there is no automatic reconnect in between. - Sending:
TextRecord→ text message withValue.WebSocketMessage→ContentByteis sent if set, otherwiseContentString(UTF-8);MessageType0= text,1= binary. Sends are serialized. - Receiving: each complete message is emitted on
OutputwithContentByte,ContentString(UTF-8 decoding of the bytes),MessageTypeandSessionId(a random id of this component instance, not from the server). Each message gets new, empty metadata, so responses can't be correlated to the input record via metadata. - A message bigger than
MaxMessageSizecloses the connection (MessageTooBig). The plugin keeps the flow running and closes the socket when the flow stops.
Notes
IgnoreCertificate=truemakes everywss://connection fail: the code rejects all server certificates instead of accepting them.TimeOutMsis not used; connect and send have no timeout of their own.- When forwarding a received
WebSocketMessagewith a changedContentString, clearContentByte, otherwise the old bytes are sent. - Errors while processing received messages are only logged.
Example
json
{ "Uri": "wss://stream.example.com/ws", "AuthType": 4, "Bearer": "=Secrets.StreamToken" }Script (subscribe message) → Web socket client (OnConnect → Script) → Output → Json deserializer → ...