Create a reconnect manager.
Optionalconfig: Partial<ReconnectConfig>Optional reconnection configuration
A new ReconnectManager instance
import { createReconnectManager } from './managers/reconnect.js';
const reconnectMgr = createReconnectManager({
maxAttempts: 10,
initialDelayMs: 1000,
maxDelayMs: 30000,
pauseOnAuthError: true
});
// Listen to reconnection events
reconnectMgr.onEvent((event) => {
console.log(`Reconnect ${event.state} (attempt ${event.attempt})`);
});
// Start reconnection
await reconnectMgr.reconnect(
() => client.connect(),
() => authHandler.refreshToken()
);
Reconnection Manager - Advanced Stand-alone Reconnection Control
Use this when you need custom reconnection behavior outside of ConnectionManager's built-in reconnection.
Decision Guide: Which Reconnection Approach?
Use ConnectionManager's built-in reconnection if you need:
Use ReconnectManager stand-alone if you need:
Example