SQL WebSocket messages and sessions¶
GET /query/ws shares workspace parsing through query workspace_id or header X-Workspace-ID. They must agree, without duplication or leading/trailing whitespace. Shared product credential subprotocols support moi-api-key/moi-bearer. After authentication, only the protocol name is echoed; credentials stay out of URLs. This handler does not call the dashboard’s extra Origin validator. Actual proxy and origin policies require environment verification, rather than a direct production-vulnerability conclusion.
After connecting, RunInteractive opens a dedicated actor database session reused for SQL execution. Cancellation uses a separate actor session and owned query_id/connection ID, then CAS-updates killed. Dashboard WS rules for an independent authorization context per business message do not apply here.
Request message_type |
data |
Response |
|---|---|---|
ping |
None |
pong, echoing message id |
query_execute |
Same parameters as run-query |
query_id first, then query_result |
query_kill |
query_id, not statement_id |
query_kill acknowledgement, echoing the cancellation request id |
preclose |
None |
Close the connection |
Top-level id correlates messages. In query_id responses, data.id is also the message id; data.query_id is the saved execution record ID. query_result contains actual operation/statement IDs and state. Both success and failure can arrive in query_result; check status/err_msg.
Pre-start validation and cancellation failures produce error messages with only data.err text, without dashboard WS status/code/msg. The outer shape contains id, message_type, and optional data, not an HTTP code/data envelope. Invalid JSON or unknown types may be silently ignored. Dashboard limits of 128-byte IDs or a single in-flight request with 409 do not apply. Multiple execution messages may target the same database connection; this does not guarantee actual SQL parallelism, out-of-order safety, or ID deduplication.
Disconnection ends the database session and request context without reversing all executed writes. After cancellation acknowledgement, check the same query_id state. A resolved frontend kill Promise does not establish database cancellation. The frontend currently has no explicit error-message case; execute waits for query_result for 30 seconds, and kill also resolves after a 10-second timeout.
Go SDK connection/send/receive support context deadlines. Python receive can set and restore timeout. Both provide query_execute/query_kill/ping/receive. CLI connect-query-web-socket only handshakes, prints the protocol, and closes; it sends no query frames. query-web-socket-url only constructs a URL. Their names do not establish a complete interactive CLI terminal.