Session
A session is an authenticated two-way link between a client and the Router, established when a client attaches to a Realm and torn down when it detaches. All WAMP interaction — calls, registrations, publications, subscriptions — happens in the context of a session.
Key characteristics:
- A session is attached to exactly one realm for its entire lifetime.
- A session is authenticated on that realm, unless the realm allows the
anonymousauthmethod. - A session is stateful: Bondy holds the session's identity, transport, and routing state for as long as it is open, rather than treating each request as an independent, unauthenticated interaction.
- Sessions are not replicated across the cluster — a session lives on the node the client is connected to.
wamp.session.get(below) is routed cluster-wide to the node that owns the requested session; the caller does not need to know which node that is.
Types
session
sessionThe session's external (client-facing) identifier, as sent in the WAMP WELCOME message.
authidThe identity the session authenticated as.
authmethodThe authentication method used to establish the session, e.g. cryptosign, wampcra, ticket, anonymous.
authproviderThe identity provider that authenticated the session. Always com.leapsight.bondy for Bondy's built-in security store.
authroleThe single active authorization role for this session, derived from the authenticated user's group memberships.
authextraExtra authentication context: session_guid (the internal, node-hash-qualified session identifier used for cluster-wide routing), node (the node the session is attached to) and, for a session that is not anonymous, meta (the user's metadata).
transportTransport-level information: the peer's peername (address and port). An internal session that has no socket has an empty map.
bondy.session.self returns this type extended with two additional fields, not present when a session is retrieved by wamp.session.get:
x_authrolesEvery authorization role assigned to the authenticated user, not just the single active authrole.
x_metaThe user's metadata, taken from authextra.meta. An empty map for an anonymous session.
Procedures
| Name | URI |
|---|---|
| Retrieve the caller's own session | bondy.session.self |
| Retrieve a session | wamp.session.get |
Retrieve the caller's own session
bondy.session.self() -> session()
Retrieves the calling session's own details — the same information returned in the WAMP WELCOME message, plus two extra fields not present in wamp.session.get's result.
Call
Positional Args
None.
Keyword Args
None.
Result
Positional Results
0The calling session, extended with x_authroles and x_meta (see below).
Keyword Results
None.
Errors
Raises bondy.error.not_found if the call somehow has no associated session — a defensive case, since a CALL always originates from an active session in practice.
Retrieve a session
wamp.session.get(session_id) -> session()
Retrieves the details of a session in the caller's realm. Bondy routes the call to whichever node owns the session, so the caller does not need to track session-to-node placement itself. The procedure takes no realm argument; a call with extra positional arguments fails with wamp.error.invalid_argument.
Call
Positional Args
0The session identifier, as returned in the session_guid field of the session object's authextra. The integer session field is not accepted: a call with it fails with wamp.error.no_such_session.
Keyword Args
None.
Result
Positional Results
0The requested session (see the session type above).
Keyword Results
None.
Errors
Raises wamp.error.no_such_session if no session with the given identifier exists on the realm, whether because it never existed, has since closed, or lived on a node that is currently unreachable. Raises the same error if the argument is not a session_guid string.
Topics
Bondy publishes these two events in the session's realm, on the topics wamp.session.on_join and wamp.session.on_leave.
wamp.session.on_join
Published when a session opens.
Positional Results
0The session that just joined (see the session type above).
Keyword Results
session_guidThe internal, node-hash-qualified session identifier Bondy uses for cluster-wide routing.
wamp.session.on_leave
Published when a session closes, whether by client disconnect, explicit GOODBYE, or the router terminating it.
Positional Results
0The external (client-facing) session identifier.
1The session's authid. For an anonymous session, Bondy generates a unique authid when the session opens.
2The session's authrole.
Keyword Results
session_guidThe internal, node-hash-qualified session identifier Bondy uses for cluster-wide routing.
See also
- Registry Routing (RIB) — how session lifecycle events feed cluster-wide routing.
- Realm — the administrative domain every session attaches to.