Skip to content

Session Resuming

Ryanlink supports Lavalink session resuming — when the WebSocket reconnects with the same session ID, Lavalink restores all player states server-side so audio continues without interruption.

const manager = new RyanlinkManager({
resuming: {
enabled: true,
timeout: 60000, // Lavalink holds the session for 60 seconds after disconnect
},
});

When the node reconnects, Ryanlink automatically calls node.updateSession() to register the session. On the nodeReady event, payload.resumed will be true if the session was successfully resumed.

manager.nodeManager.on('nodeReady', (node, payload) => {
if (payload.resumed) {
console.log(`Node ${node.id} resumed — session: ${payload.sessionId}`);
} else {
console.log(`Node ${node.id} connected fresh — session: ${payload.sessionId}`);
}
});

To resume a specific session after a bot restart, pass sessionId in the node config:

nodes: [{
id: 'main',
host: 'localhost',
port: 2333,
authorization: 'youshallnotpass',
sessionId: 'your-previous-session-id',
}]

Ryanlink will include this session ID in the WebSocket handshake headers, allowing Lavalink to resume the session.


Ryanlink keeps a circular buffer of previously played tracks per player:

queueOptions: {
maxPreviousTracks: 25, // default
}
// Access in your commands
const prev = player.queue.previous; // Track[]

For unresolved tracks (e.g. Spotify metadata resolved to YouTube), configure retry behavior:

const manager = new RyanlinkManager({
trackResolveRetryLimit: 3, // global default
autoSkipOnResolveError: true, // skip to next track on failure
});
// Or per-player
manager.createPlayer({
guildId: '...',
voiceChannelId: '...',
trackResolveRetryLimit: 5,
});

When all retries are exhausted, trackError is emitted and the track is skipped if autoSkipOnResolveError is true.


Configure what happens when the bot is disconnected from voice:

playerOptions: {
onDisconnect: {
destroyPlayer: false, // don't destroy the player
autoReconnect: true, // reconnect automatically
autoReconnectOnlyWithTracks: true, // only reconnect if queue has tracks
},
}

When autoReconnect: true:

  1. player.connect() is called to rejoin the voice channel
  2. If player.queue.current exists, player.play({ position, paused }) resumes from the last position
  3. If only player.queue.tracks has items, player.play() starts the next track
  4. If the reconnect fails, player.destroy(DestroyReasons.PlayerReconnectFail) is called