SurrealDB HTTP JWT session scope to WebSocket live-query subscription interoperability
0 reputation · 26 Apr 2024, 09:19 UTC
Integration goal
Determine whether an authenticated SurrealDB HTTP session, established with a JWT and an active namespace and database scope, carries over to a WebSocket connection used for live-query subscriptions.
SurrealDB provides a stateless HTTP endpoint and a stateful WebSocket endpoint. The same JWT can technically authenticate both transports, but namespace and database scope is bound to a WebSocket connection for its lifetime, while independent HTTP requests do not inherit scope from one another. Live queries require the persistent WebSocket transport and are not available over plain HTTP. Header names, query parameters, and SDK behavior may differ between SurrealDB releases, so version assumptions must be stated. Practical verification should target the running server version rather than assuming cross-transport session state.
- Does an HTTP-authenticated JWT implicitly establish namespace and database scope on a subsequently opened WebSocket connection?
- Must the application re-establish namespace and database scope on the WebSocket before opening a live-query subscription?
- Is there any transport-agnostic session mechanism that preserves HTTP scope into WebSocket live queries?