Node represents a connection to a single Lavalink server. Nodes handle WebSocket communication, REST API calls, and track loading.
Node Configuration
Configure a node withNodeConfig:
Unique identifier for the node
Node address in
host:port format (e.g., localhost:2333)Authorization password matching the Lavalink server configuration
Use secure connections (wss:// and https:// instead of ws:// and http://)
Previous session ID for resuming sessions after reconnection
Connection Status
Nodes have four possible states:Initial connection in progress
Successfully connected and ready
Lost connection, attempting to reconnect
Not connected (initial state or after Close())
Connection Lifecycle
Opening Connections
Nodes automatically connect when added to the client:AddNode() returns after successfully establishing a connection. If connection fails, it will automatically retry with exponential backoff (max 30s delay).Automatic Reconnection
Nodes automatically reconnect if the connection is lost:- Reconnect Delay: Starts at 0s, increases by 2s per attempt, maximum 30s
- Exponential Backoff:
delay = min(try * 2s, 30s) - Unlimited Retries: Continues until successful or explicitly closed
Closing Connections
Manually close a node connection
Session Resuming
Lavalink supports resuming sessions to preserve player state across reconnections:Initial Setup
Update node session configurationSessionUpdate Fields:
Resuming: Enable/disable session resumingTimeout: How long (in seconds) Lavalink keeps the session after disconnect
Resuming After Restart
Store the session ID and provide it when reconnecting:When a session is successfully resumed, DisGoLink automatically syncs all player states from the server.
Load Balancing
DisGoLink includes built-in load balancing based on node statistics:Select the node with the best performance metrics
- Lowest CPU load
- Lowest memory usage
- Lowest system load
- First node (if all metrics are equal)
Node statistics are automatically updated via the
StatsMessage event from Lavalink.Node Statistics
Get current node performance metrics
- CPU load (Lavalink and system)
- Memory usage (used, free, allocated, reservable)
- Uptime
- Active player count
- Frame statistics (sent, nulled, deficit)
Node Information
Get the current session ID for this node
Get the node’s configuration
Get the parent client instance
Get the Lavalink server version
Get detailed server information (version, plugins, source managers, filters)
REST Client Access
Access the node’s REST API client for direct API calls
Track Loading
Load tracks by identifier (URL or search query)
Load tracks with a callback handler for results
Decode a single encoded track string
Decode multiple encoded track strings