Skip to main content
SessionEvent is delivered via ws.session_events() — separate from updates() so a single reconnect is one event, not one per subscribed market.

Connected

Initial socket establishment. Fires once per call to connect().

Reconnected

Socket re-established after an observed outage.
FieldType
gap_msu64 — wall-clock gap between last received message and recovery
Callers maintaining cached books should discard them and wait for fresh WsUpdate::Snapshot events on each subscribed market.

Lagged

The outbound dispatch channel overflowed: a slow consumer missed deltas. OpenPX raises this explicitly rather than silently skipping (the way tokio::sync::broadcast would).
FieldType
droppedu64
first_sequ64
last_sequ64
A Lagged event is followed by a BookInvalidated { reason: Lag } for every affected market.

BookInvalidated

A specific market’s book is no longer trustworthy. Discard your cache for that market_id; the next WsUpdate::Snapshot will rebuild it.
FieldType
market_idstring
reasonInvalidationReason
InvalidationReason: Reconnect, Lag, SequenceGap { expected, received }, ExchangeReset.

Error

A non-fatal error observed on the connection. The session continues; surface this for logging or alerting.
FieldType
messagestring

Pattern matching (Python)

from openpx import Connected, Reconnected, Lagged, BookInvalidated, SessionError

for event in ws.session_events():
    match event:
        case Connected():
            ...
        case Reconnected(gap_ms):
            ...
        case Lagged(dropped, first_seq, last_seq):
            ...
        case BookInvalidated(market_id, reason):
            ...
        case SessionError(message):
            ...