Skip to content

WebSocketClient

std/websocket-client@1. Opens a peer Session. Each complete message is one value; each graph write is journaled before I/O. One terminal ends the Session, not a message.

This declaration comes from crates/rastok/src/lab.rs. Place the Connector in a Graph and wire its ports; the excerpt alone is not an App.

connector network : WebSocketClient {
url = "wss://example.test/socket"
handshake_timeout = duration("5s")
codec = json
behavior = deterministic
}

The contract index explains shared settings, build features and the distinction between a Contract, a Lab model and an installed Driver.

See instance ownership and bounded admission; this Contract uses Sessions, not the outbound Call queue rule.

ModeDriver directionExchangeLab modelInstalled in this binary
No selectorinbound+outboundsessionlab-websocketNot compiled
ModePortDirectionType rule
allininputcodec = bytes → array<byte>; codec = json → variant; codec = string → string
alloutoutputSame as in
allexitoutputWebSocketExit, below
ModeOutput cardinality
allZero or more frames and writes; exactly one exit per Session
CasePayloadCall visibility
Closed{ code: int, reason: string }Not an outbound Call
ConnectFailedEmptyNot an outbound Call
DecodeFailedEmptyNot an outbound Call
DnsFailedEmptyNot an outbound Call
HandshakeRejected{ status: int }Not an outbound Call
MessageTooLarge{ limit: ulong }Not an outbound Call
OutcomeUnknownEmptyNot an outbound Call
ProtocolFailedEmptyNot an outbound Call
TimeoutExpiredEmptyNot an outbound Call
TlsFailedEmptyNot an outbound Call
TransportLostEmptyNot an outbound Call

With codec = json, rastok check refuses a producer whose resolved type contains a value without a JSON form, using E-TYPE-INVALID. A variant producer is checked at execution instead: an unencodable message ends the Session with DecodeFailed before it is sent.

ModeSettingDomainPresence / defaultLatest phase
allauth_bearerstringoptionalinstance
allbehaviordeterministic | probabilisticrequiredplan
allcodecbytes | json | stringrequiredplan
allhandshake_timeoutdurationrequiredinstance
allheadersHTTP headersoptionalinstance
allcustom_headersmap<string,array<string>>optionalinstance
allmax_messageByteSize"8MiB"plan
allsubprotocolsarray<string>optionalinstance
alltls_caarray<byte>optionalinstance
alltls_certificatearray<byte>optionalinstance
alltls_private_keyarray<byte>optionalinstance
allurlstringrequiredinstance
allversionsarray<http/1.1 | http/2 | http/3>["http/3", "http/2", "http/1.1"]plan
allzero_rttdisableddisabledplan

The Lab has an effectless Session binding, but authored WebSocket Session mocks are not executable. rastok check refuses a mock on this Connector with E-CHECK-DEFERRED; a declaration without a mock still checks. Driver tests cover Session opening, frames, writes and terminal outcomes separately. Input after a terminal may open a successor Session; old writes are not resent automatically.

No dedicated full-Contract fixture is declared. Related tests: crates/rastok/src/connector/drivers/network/websocket.rs.

Diagram