Ansekai DocsAnsekai docs
All pages
Connections and security
Examples

Connections and security

Connections

Every module answers on every connection. The settings of a module say which one it wants, and the SDK moves there by itself.

ConnectionGood for
HTTPSimple requests, nothing to keep open
WebSocketA live connection that works in browsers too
WebTransportUDP in browsers, a call that waits never holds back another connection. The WebSocket takes over where UDP is blocked
TCPA live connection that keeps the order
UDPThe lowest delay, for fast moving games

A client starts on HTTP. When an answer says that the module wants another connection, the next calls move there. A browser can't open TCP or UDP. A module on TCP or UDP names what browsers take instead in its settings: WebTransport, WebSocket or both, both by default. With both a browser tries WebTransport first and takes the WebSocket where UDP is blocked. Only this connection lets those in too, so browsers keep working when a module only takes TCP or UDP. A module that wants WebTransport moves a browser there. When UDP is blocked the SDK takes the WebSocket for it and doesn't try WebTransport again until the page is opened again. A failed move never breaks a call, the client keeps the connection it has.

WebTransport carries the same calls and changes as the WebSocket, on a stream of its own, over HTTP/3 on the UDP port of ANSEKAI_WEBTRANSPORT_PORT. Browsers only speak it over HTTP/3, there is no WebTransport over HTTP/2 in any of them, so the WebSocket is the way over TCP. Node has no WebTransport, it takes TCP or UDP.

Delivery on UDP

DeliveryWhat happens to a lost message
ReliableAlways arrives, in the order it was sent
Reliable unorderedAlways arrives, the order can change
SequencedOnly the newest counts, old ones are dropped
UnreliableThe fastest, a message can be lost

Security

HTTP and WebSocket are protected by TLS, WebTransport by the TLS of QUIC. TCP and UDP get a session key over TLS from /api/link/session, then every packet is sealed with the encryption the module picks:

Encryption
ChaCha20-Poly1305The default, fast on every device
AES-256-GCM, AES-128-GCMFast on chips with AES support
AES-256-GCM-SIV, AES-128-GCM-SIVStay safe if a nonce ever repeats
ARIA-256-GCMThe Korean standard, for local rules

The key can also come from a quantum safe key exchange, ML-KEM-512, 768 or 1024. The client sends its public key, the server answers with a ciphertext and only the client can open it.

Only this connection

A module can refuse every other connection. Turning it on can wait a few hours or days, so players who are online with an older build aren't cut off at once. While it is off, a client that comes another way still gets an answer and is told where to go. A game that ships the Web SDK keeps HTTP open next to it.

Rooms

A room template picks its connection the same way, a browser always joins a room with a WebSocket. See Rooms.

Updated November 21, 2026

Connections · Ansekai Docs