Skip to content

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 ​

PinKindTypesDescription
InputinputViaducta.Plugins.Http.Types.WebSocketMessage, Viaducta.Plugins.TextPlugin.Types.TextRecordMessage to send. Connects first if needed.
OutputoutputViaducta.Plugins.Http.Types.WebSocketMessageCalled for every message received from the server.
StartstartOpens the connection. Called by the system at flow start when unconnected.
OnConnecton connectViaducta.Plugins.Http.Types.WebSocketMessageCalled (with an empty message) after each successful (re)connect, e.g. to send a subscribe message.

Configuration ​

FieldTypeDefaultDescription
UristringServer URL, ws://host:port/path or wss://....
AuthTypedropdown: 0 None, 1 Basic, 2 Digest, 3 NTLM, 4 Bearer, 5 Jwt, 6 OAuth1, 7 OAuth2, 8 Other, 9 ClientCertificate0Authentication of the opening HTTP handshake.
DomainstringWindows domain (AuthType 3).
UsernamestringUser name (AuthType 1, 2, 3).
PasswordpasswordPassword (AuthType 1, 2, 3).
BearerstringWritten as-is into the Authorization header (AuthType 4, 5, 7), so include the scheme: Bearer eyJ....
ConsumerKeystringOAuth 1.0a consumer key (AuthType 6), signed as GET on Uri.
ConsumerSecretstringOAuth 1.0a consumer secret (AuthType 6).
AccessTokenstringOAuth 1.0a access token (AuthType 6).
TokenSecretstringOAuth 1.0a token secret (AuthType 6).
AuthorizationstringComplete Authorization header value (AuthType 8).
ClientCertificatecertificateName of a certificate object in the repository (AuthType 9).
MaxMessageSizeinteger1048576Max size of a received message in bytes.
IgnoreCertificatebooleanfalseBroken, see Notes. Leave false.
Headersdictionary (JSON object)Headers for the opening handshake only, e.g. {"X-Client":"viaducta"}.
TimeOutMsinteger30000Ignored.

Behaviour ​

  • The connection is opened on Start or on the first input. If it is closed (by the server or a network error), the next input or Start call reconnects; there is no automatic reconnect in between.
  • Sending: TextRecord → text message with Value. WebSocketMessage → ContentByte is sent if set, otherwise ContentString (UTF-8); MessageType 0 = text, 1 = binary. Sends are serialized.
  • Receiving: each complete message is emitted on Output with ContentByte, ContentString (UTF-8 decoding of the bytes), MessageType and SessionId (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 MaxMessageSize closes the connection (MessageTooBig). The plugin keeps the flow running and closes the socket when the flow stops.

Notes ​

  • IgnoreCertificate = true makes every wss:// connection fail: the code rejects all server certificates instead of accepting them.
  • TimeOutMs is not used; connect and send have no timeout of their own.
  • When forwarding a received WebSocketMessage with a changed ContentString, clear ContentByte, 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 → ...

Viaducta documentation