Error code reference
The API token was not provided in the WebSocket connection headers.Behavior: The connection terminates immediately and does not attempt to reconnect.Resolution: Ensure you include the
token header when establishing the WebSocket connection.The API token provided is not valid or does not exist in the system.Behavior: The connection terminates immediately and does not attempt to reconnect.Resolution: Verify that your API token is correct and has not expired. You may need to generate a new token.
The API token is already being used by another active WebSocket connection.Behavior: The connection terminates. Reconnection behavior depends on the
reconnectOnDuplicateConnection configuration:- If enabled, the client will attempt to reconnect
- If disabled, the connection terminates without reconnecting
The API token has been deleted from the system.Behavior: The connection terminates immediately and does not attempt to reconnect.Resolution: Generate a new API token and update your configuration.
Reconnection behavior
For error codes 4001, 4002, and 4004, the client will not attempt to reconnect as these represent permanent authentication failures. For error code 4003, reconnection depends on yourreconnectOnDuplicateConnection configuration setting.
All other close codes trigger an automatic reconnection attempt with exponential backoff, starting at 31 seconds and doubling up to the maxReconnectInterval value.
Example error handling
The client logs errors to the console when verbose logging is enabled:Enable
verboseLogging in your configuration to receive Discord webhook notifications when these errors occur.