why deepstreamHub? compare us getting started feature roadmap faq
use cases pricing
products
developers
company
blog contact

You can finely tune your client SDK to meet your specific requirements, including reconnection behaviour and granular timeouts using options. These are passed to the client upon initialisation.

JavaScript

const deepstream = require('deepstream.io-client-js')
const client = deepstream( '<YOUR APP URL>', {
  mergeStrategy: deepstream.LOCAL_WINS,
  subscriptionTimeout: 500,
})

Java

import java.util.*;
import io.deepstream.*;

Properties options = new Properties();
options.setProperty( ConfigOptions.SUBSCRIPTION_TIMEOUT , 500 );
options.setProperty( ConfigOptions.MERGE_STRATEGY , MergeStrategy.LOCAL_WINS );

DeepstreamFactory factory = DeepstreamFactory.getInstance();
DeepstreamClient client = factory.getClient( "Your app url", options );

Info

  • All of deepstreamHub's SDKs support the same configuration options. However, following the conventions of the various programming languages, options in javascript are specified in camel-case, e.g. subscriptionTimeout whereas other languages use upper-case ENUM constants, e.g. ConfigOptions.SUBSCRIPTION_TIMEOUT for Java. This reference lists the camel-case variant.

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

Reconnection Options

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

maxReconnectInterval

Specifies the upper ceiling for the reconnect interval. Once this number is reached the SDK won't further increase the time between reconnection attempts. Type: Number
Default: 180000

maxReconnectAttempts

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

Timeouts

rpcAckTimeout

The number of milliseconds after which a RPC will error if no Ack-message has been received.
Type: Number
Default: 6000

rpcResponseTimeout

The number of milliseconds after which a RPC will error if no response-message has been received.
Type: Number
Default: 10000

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

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

Data

The following options can be used to fine-tune the client behaviour for performance critical apps. Use with caution!

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

recordDeepCopy

JavaScript SDK only: Setting to false disabled deepcopying of record data when provided via get() in a subscribe callback. This improves speed at the expense of the user having to ensure object immutability. Type: Boolean
Default: true