SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

Constructor #

This constructor creates a new WebSocket connection, using the specified options.

Arguments #

WebSocket(host, [options]);

ArgumentTypeDescription
host
string
Kuzzle server hostname or IP
options
object
WebSocket connection options

options #

WebSocket protocol connection options.

PropertyType
(default)
Description
autoReconnect
boolean

(true)
Automatically reconnect to kuzzle after a disconnected event
port
number

(7512)
Kuzzle server port
headers
object
({})
Connection HTTP headers (e.g. origin, subprotocols, ...)
(Not supported by browsers)
reconnectionDelay
number

(1000)
Number of milliseconds between reconnection attempts
sslConnection
boolean

(false)
Use SSL to connect to Kuzzle server

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);