Skip to main content

Configuration

Full Configuration Reference

new RealtimeClient({
// Required — broker credentials
endpoint: {
host: "broker.example.com",
port: 443,
scheme: "wss",
path: "/mqtt",
clientId: "my-client",
username: "user",
password: "token",
cleanSession: false,
keepAliveSeconds: 15,
},

// Optional — auto-recover from expired tokens
onAuthFailure: async () => {
const fresh = await myApi.refreshToken();
return { host: "...", port: 443, ...fresh };
},

// Optional — timing
reconnectInterval: 50,
handshakeTimeout: 30000,
heartbeatTimeout: 10000,

// Optional — retry backoff
retryBackoff: {
baseSeconds: 1,
ceilSeconds: 60,
},

// Optional — subscription health audit
topicAudit: {
enabled: true,
intervalMs: 10000,
},
});

Configuration Options

OptionTypeDefaultDescription
endpointEndpointConfigrequiredBroker connection parameters
onAuthFailure() => Promise<EndpointConfig>Called on auth error; returns fresh credentials
reconnectIntervalnumber50ms between auto-reconnect attempts
handshakeTimeoutnumber30000ms to wait for CONNECT acknowledgement
heartbeatTimeoutnumber10000ms to wait for PINGRESP before marking stale
retryBackoff.baseSecondsnumber1Initial retry delay in seconds
retryBackoff.ceilSecondsnumber60Maximum retry delay in seconds
topicAudit.enabledbooleanfalseEnable periodic subscription verification
topicAudit.intervalMsnumber10000Audit interval in milliseconds