Constructor #
This constructor creates a new WebSocket connection, using the specified options.
Arguments #
WebSocket(host, [options]);
Argument | Type | Description |
---|---|---|
host | string | Kuzzle server hostname or IP |
options | object | WebSocket connection options |
options #
WebSocket protocol connection options.
Property | Type (default) | Description |
---|---|---|
autoReconnect | boolean ( true ) | Automatically reconnect to kuzzle after a disconnected event |
headers | object( {} ) | Connection custom HTTP headers (e.g. origin, subprotocols, ...) (Not supported by browsers) |
pingInterval | number ( 2000 ) | Number of milliseconds between two pings |
port | number ( 7512 ) | Kuzzle server port |
reconnectionDelay | number ( 1000 ) | Number of milliseconds between reconnection attempts |
sslConnection | boolean ( false ) | Use SSL to connect to Kuzzle server Deprecated since 7.4.0 |
ssl | boolean ( false ) | Use SSL to connect to Kuzzle server. Defaults to true for ports 443 and 7443. |
Return #
A WebSocket
protocol instance.
Usage #
// Loads the WebSocket protocol
const
{
Kuzzle,
WebSocket
} = require('kuzzle-sdk');
const options = {
autoReconnect: false
};
// Instantiates the websocket protocol
const websocketProtocol = new WebSocket('kuzzle', options);
// Use it with Kuzzle
const kuzzle = new Kuzzle(websocketProtocol);
Edit this page on Github(opens new window)