Skip to content

WebSocketServer

std/websocket-server@1. Accepts peer Sessions. Replies follow session lineage or an explicit correlate. A pre-admission handshake refusal creates no Session or exit.

This declaration comes from examples/agent-gateway.rkg. Place the Connector in a Graph and wire its ports; the excerpt alone is not an App.

connector clients : WebSocketServer {
listen = "127.0.0.1:8443"
path = "/agent"
codec = json
handshake_timeout = duration("5s")
max_message = "1MiB"
correlate = meta.ext.session_id
versions = ["http/1.1"]
}

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
allallowed_originsarray<string>optionalinstance
allauth_bearerstringoptionalinstance
allbehaviordeterministicdeterministicplan
allcodecbytes | json | stringrequiredplan
allcorrelatestringoptionalinvocation
allhandshake_timeoutdurationrequiredinstance
allheadersHTTP headersoptionalinstance
allcustom_headersmap<string,array<string>>optionalinstance
alllistenstringrequiredinstance
allmax_messageByteSize"8MiB"plan
allpathstring"/"plan
allsubprotocolsarray<string>optionalinstance
alltls_certificatearray<byte>optionalinstance
alltls_private_keyarray<byte>optionalinstance
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 and terminal outcomes separately from a physical listener, authentication or wire handshake. Explicit correlation never chooses another Connector’s Session.

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

Diagram