Skip to content

WebSocket Connection

Zenith messages are sent via WebSocket frames.

Zenith supports several serialisation formats for its publish/subscribe infrastructure, negotiated via the Sec-WebSocket-Protocol header. Clients should list their desired protocols in order of decreasing preference, and the Server will reply with the final protocol to use.

FormatName in Sec-WebSocket-Protocol headerFrame Type
JSONZenithJsonText
BSONZenithBsonBinary
Message PackZenithMsgPackBinary

Example Client RequestHeader:

Sec-WebSocket-Protocol: ZenithJson,ZenithBson, ZenithMsgPack

Example Server ResponseHeader:

Sec-WebSocket-Protocol: ZenithJson

All messages take the same structure in all serialisation formats, so the formats are interchangeable. Property names should be considered case-sensitive.

Zenith is intended to be backwards compatible with older clients. To enable this in your client, you must pass a version query parameter in your initial HTTP request.

VersionNotable Changes
1.6Legacy Version
2.0Current Public Release

If you do not request a specific version, you will receive the most recent protocol. The protocol version can be retrieved from the ServerInfo subscription on the Zenith Controller.

Example URL with data protocol version:

http://staging-websocket.paritech.com/Zenith?version=2.0

When a WebSocket connection is closed by the Client, the Server will send one of the following standard codes as an explanation.

CodeNameDescription
1000NormalSent in response to a client-initiated closure.
1001GoingAwaySent if the server deliberately dropped your connection.
1002ProtocolSent if the client supplies an invalid or malformed frame.
1007DataInvalidSent if the client supplies an invalid packet.
1008ViolatesPolicySent if the client has not responded to ping.
1009DataTooLargeSent if the client sends a message that is too large.
1011ServerErrorSent if the server encountered a situation requiring it to end the connection.
1012ServerRestartSent if the server is shutting down. The client should attempt to reconnect.

Zenith also defines the following application-specific close codes.

CodeNameDescription
4000SessionSent if this Connection is being dropped due to a concurrent login exceeding the limits of your account.