All configuration options are passed as a single object to theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/foxytp/stelar-time-real/llms.txt
Use this file to discover all available pages before exploring further.
StelarServer constructor. Every option is optional — sensible production defaults are applied automatically.
Connection
The HTTP/WebSocket port to listen on. Defaults to
3000. Ignored when server is provided. If the port is already in use, stelar-time-real automatically increments until a free port is found.Attach to an existing Node.js
http.Server instance instead of creating a new one. Useful when sharing a port with Express, Fastify, or another HTTP framework.WebSocket upgrade path. Only WebSocket upgrade requests matching this path are accepted. Defaults to
'/'. Use a custom path (e.g. '/realtime') to colocate stelar-time-real on a server that also serves regular HTTP.Port for the custom binary TCP server. Set to
false to disable TCP entirely (WebSocket only). When omitted, TCP is disabled by default. TCP is only useful for Node.js-to-Node.js communication — browsers cannot use it.Connection Limits
Maximum number of concurrent connections across all protocols. New connections are rejected once this limit is reached and the
onMaxConnectionsReached hook fires. Defaults to 10000.Maximum number of simultaneous connections from the same IP address. Prevents bots and brute-force attacks. Defaults to
50. Ignored when customIPTracker is provided.Global cap on the total number of active rooms. When reached, new room creation is blocked and
onMaxRoomsReached fires. Defaults to 10000.Maximum number of rooms a single client can join. When exceeded, the join is silently dropped and
onMaxRoomsPerClientReached fires. Defaults to 50.Maximum incoming message payload size in bytes. Messages exceeding this are dropped and
onPayloadTooLarge fires. Defaults to 10485760 (10 MB).Maximum WebSocket frame size in bytes. Frames exceeding this trigger a protocol-level close. Defaults to
10485760 (10 MB). Applies to both WebSocket and TCP framing.Rate Limiting
Global token-bucket rate limit applied to every connected client. See Rate Limiting for per-event and per-client overrides.
maxPoints is the maximum number of messages allowed per windowMs millisecond window.Set to false to disable the built-in rate limiter entirely. Defaults to { maxPoints: 100, windowMs: 1000 }.A map of event name to rate limit config. Each entry defines an independent token bucket for that specific event, evaluated in addition to the global limit.
Replace the built-in token-bucket rate limiter with your own implementation. Must implement the
IRateLimiter interface: check(id, cost?), reset(id), cleanup(), size(). See Extensibility for a Redis example.Timeouts
How often (in milliseconds) the server sends a ping to each connected client. Defaults to
30000 (30 s). Use a lower value for faster dead-connection detection at the cost of more network traffic.How long (in milliseconds) the server waits for a pong response before forcibly disconnecting the client. Defaults to
60000 (60 s), which is heartbeatInterval × 2 when omitted.Maximum time in milliseconds a WebSocket upgrade request may stay pending before the raw socket is destroyed. Defaults to
10000 (10 s).Graceful Shutdown
When
true, installs SIGINT/SIGTERM signal handlers that stop accepting new connections, notify existing clients with a close frame, and wait for them to disconnect cleanly. Defaults to true. Signal handlers are removed when stelar.stop() is called to prevent MaxListenersExceeded warnings on multiple instances.Maximum time in milliseconds to wait for open connections to close during graceful shutdown. After this timeout, remaining sockets are forcibly destroyed. Defaults to
10000 (10 s).Health Check
URL path for the built-in HTTP health check endpoint. Compatible with Kubernetes liveness/readiness probes, Docker Swarm health checks, and load balancers. Defaults to
'/health'. Set to false to disable.The response includes: status, totalConnections, activeConnections, totalMessagesReceived, totalMessagesSent, totalRooms, uptime, wsConnections, tcpConnections, memoryMB, and rateLimiterEntries.Replace the built-in health handler with your own function. Receives the raw
IncomingMessage, ServerResponse, and the current StelarStats object. See Extensibility for a full example.Security
Whitelist of origins that are permitted to open WebSocket connections. Requests with an
Origin header not in this list receive a 403 Forbidden response. Pass null or omit the option to allow all origins. The same list is used to set Access-Control-Allow-Origin on the health endpoint.Enable TLS for both
wss:// WebSocket and TCP connections. Pass an object with key and cert (as Buffer or string).Enable
permessage-deflate WebSocket compression. Negotiated per-client — only clients that advertise compression support receive compressed frames. Defaults to false.Logging
Controls server-side logging. Pass a log level string, a custom
Logger instance, or false to silence all output. Defaults to 'info'.| Level | Output |
|---|---|
'debug' | Verbose internal events |
'info' | Start/stop, connections, shutdowns |
'warn' | Rate limits, invalid messages, oversized payloads |
'error' | Handler exceptions, write failures |
'silent' | Nothing |
Extensibility
Replace the built-in per-IP connection tracker. Must implement
check(ip), add(ip), remove(ip), getCount(ip), and cleanup(). Useful for Redis-backed tracking or IP blocklists. See Extensibility.Custom function to generate unique client IDs. By default uses
crypto.randomUUID() (UUID v4). Return any string — it must be unique per connection.Hooks
Lifecycle callbacks for internal server events. Each hook can optionally return
false to cancel the default action (disconnect, reject join, etc.). See the Hooks reference for the full list.