Options

Options are passed to the client upon initialisation

const { DeepstreamClient } = require('@deepstream/client')
const client = deepstream( 'localhost:6020', {
  // custom deepstream options
  mergeStrategy: deepstream.LOCAL_WINS,
  subscriptionTimeout: 500,
})

You can finely tune deepstream to meet your specific requirements, including reconnection behaviour and granular timeouts.

General Configuration

mergeStrategy

A global merge strategy that is applied whenever two clients write to the same record at the same time. Can be overwritten on a per record level. Default merge strategies are exposed by the client constructor. It’s also possible to write custom merge strategies as functions. You can find more on handling data conflicts here
Type: Function
Default: MERGE_STRATEGIES.REMOTE_WINS

reconnectIntervalIncrement

Specifies the number of milliseconds by which the time until the next reconnection attempt will be incremented after every unsuccessful attempt.
E.g.for 1500: if the connection is lost,the client will attempt to reconnect immediately, if that fails it will try again after 1.5 seconds, if that fails it will try again after 3 seconds and so on…
Type: Number
Default: 4000

heartbeatInterval

The number of milliseconds to wait before sending a heartbeat. If two heatbeats are missed in a row the client will consider the server to have disconnected and will close the connection in order to establish a new one.
Note: If client heartbeatInterval > 2 * server heartbeatInterval the client will be considered as disconnnected by the server if no other messages are sent.

Type: Number
Default: 30000

maxReconnectAttempts

The number of reconnection attempts until the client gives up and declares the connection closed.
Type: Number
Default: 5

subscriptionTimeout

The number of milliseconds that can pass after providing/unproviding a RPC or subscribing/unsubscribing/listening to a record or event before an error is thrown.
Type: Number
Default: 2000

maxMessagesPerPacket

If your app sends a large number of messages in quick succession, the deepstream client will try to split them into smaller packets and send these every ms. This parameter specifies the number of messages after which deepstream sends the packet and queues the remaining messages. Set to Infinity to turn the feature off.
Type: Number
Default: 100

timeBetweenSendingQueuedPackages

Please see description for maxMessagesPerPacket. Sets the time in ms.
Type: Number
Default: 16

recordReadAckTimeout

The number of milliseconds from the moment client.record.getRecord() is called until an error is thrown since no ack message has been received.
Type: Number
Default: 1000

recordReadTimeout

The number of milliseconds from the moment client.record.getRecord() is called until an error is thrown since no data has been received.
Type: Number
Default: 3000

recordDeleteTimeout

The number of milliseconds from the moment record.delete() is called until an error is thrown since no delete ack message has been received. Please take into account that the deletion is only complete after the record has been deleted from both cache and storage.
Type: Number
Default: 3000

offlineEnabled

Enable offline record support using indexdb to store data client side.
Type: Boolean
Default: false

See all options in source repo.