Connection Parameters#
Parameter Details#
| Parameter | Type | Default | Description |
|---|
| auth | object | - | Authentication object containing the token |
| reconnection | boolean | true | Whether to automatically reconnect |
| reconnectionAttempts | number | 10 | Number of reconnection attempts before giving up |
| reconnectionDelay | number | 2000 | Initial delay between reconnection attempts (ms) |
| reconnectionDelayMax | number | 10000 | Maximum delay between reconnection attempts (ms) |
| transports | array | ['websocket'] | Array of allowed transport methods |
| forceNew | boolean | true | Force a new connection instead of reusing existing |
To get the access token please refer to the Authentication page in the 360X API reference section of the documentation.
Establishing Connection#
Connecting to a Single Namespace#
Connecting to Multiple Namespaces#
Event Handling#
Connection Events#
Error Events#
Data Events#
Subscription Response#
{
"message": "Subscription successful to {namespace}"
}
Clean Disconnection#
Error Handling#
Unhandled Promise Rejections#
Uncaught Exceptions#
Complete Connection Example#
Best Practices#
1.
Always implement reconnection logic
2.
Handle all possible socket events
3.
Implement proper cleanup on application shutdown
4.
Log all errors and connection state changes
5.
Monitor connection health
6.
Implement exponential backoff for reconnection attempts
7.
Clean up event listeners when disconnecting
8.
Handle authentication token expiration
9.
Implement proper error recovery strategies
Modified at 2025-05-05 08:22:20