GioJSdocs
On this page

[websocket]

WebSocket routes (route.ts files that export wsHandler): the switch, the connection cap and server pings.

gio.toml
[websocket]
max_connections = 5000
ping_interval_secs = 25

The Origin check on upgrades lives in [security.websocket]. The WebSockets guide covers handlers, rooms and the client.

Reference

KeyDefaultDescription
enabledbooleantrueAccept WebSocket upgrades and connect them to the worker's wsHandlers. Off, no socket is ever opened. The origin check still runs first, so a cross-site upgrade gets its 403 instead.0 / false / empty: Upgrades are answered 501
max_connectionsinteger1000Open WebSockets across the server. A socket over the cap is accepted and immediately closed with 1013 (try again later), reason too many connections, which clients read as a reason to back off and retry.0 / false / empty: Unlimited. Warns.
ping_interval_secsinteger30Ping every socket this often, so a peer that vanished is noticed when the ping cannot be sent and the socket is closed. The first ping goes out one interval after the connection opens.0 / false / empty: No server pings

Behavior

  • Open sockets are not counted by [server] max_connections, and the connection timeouts in [server] never close them.
  • A path whose module exports no wsHandler closes the socket with 4404; an async handler whose promise rejects closes it with 1011. See Close codes.
  • If the server cannot connect to the worker's WebSocket channel at startup, it logs WS IPC connect failed - WebSocket disabled and answers upgrades 501 as if enabled were false.

Startup warnings

WhenStartup warning
max_connections = 0 while enabled[websocket] max_connections = 0: WebSocket connections are unlimited - every open socket holds memory and a file descriptor

Examples

No WebSockets

gio.toml
[websocket]
enabled = false

Behind a proxy with a 60-second idle timeout

Pings keep the connection busy, so the proxy does not close a quiet socket:

gio.toml
[websocket]
ping_interval_secs = 25

Good to know

  • 0 means unlimited for max_connections and no pings for ping_interval_secs. To refuse WebSockets, use enabled = false.
  • Each open socket holds a file descriptor: keep the process limit (ulimit -n) above [server] max_connections plus this cap.
  • In a worker pool each socket stays on one worker; room broadcasts reach sockets on every worker.

Version history

VersionChanges
v0.1.0-beta.8max_connections = 0 means unlimited (it closed every socket with 1013) and logs a startup warning; ping_interval_secs = 0 means no pings (it crashed every connection).
v0.1.0-beta.1Introduced with enabled, max_connections and ping_interval_secs.