Skip to content

Commit

Permalink
Updated max reconnect to retry forever (#220)
Browse files Browse the repository at this point in the history
* Updated maxReconnect to retry forever

* Updated README

* Updated unlimited reconnection guide
  • Loading branch information
tbazen authored Dec 7, 2023
1 parent e527d57 commit 9f161c7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ await memphis.connect({
connectionToken: "<broker-token>", // you will get it on application type user creation
password: "<string>", // depends on how Memphis deployed - default is connection token-based authentication
reconnect: true, // defaults to true
maxReconnect: 10, // defaults to 10
maxReconnect: 10, // The default value is -1 which means reconnect indefinitely
reconnectIntervalMs: 1500, // defaults to 1500
timeoutMs: 15000, // defaults to 15000
// for TLS connection:
Expand Down
4 changes: 2 additions & 2 deletions lib/memphis.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Memphis {
this.accountId = 1;
this.connectionToken = '';
this.reconnect = true;
this.maxReconnect = 10;
this.maxReconnect = -1;
this.reconnectIntervalMs = 1500;
this.timeoutMs = 15000;
this.brokerConnection = null;
Expand All @@ -79,7 +79,7 @@ class Memphis {
this.stationPartitions = new Map();
this.seed = 31;
}
connect({ host, port = 6666, username, accountId = 1, connectionToken = '', password = '', reconnect = true, maxReconnect = 10, reconnectIntervalMs = 1500, timeoutMs = 2000, keyFile = '', certFile = '', caFile = '', suppressLogs = false }) {
connect({ host, port = 6666, username, accountId = 1, connectionToken = '', password = '', reconnect = true, maxReconnect = -1, reconnectIntervalMs = 1500, timeoutMs = 2000, keyFile = '', certFile = '', caFile = '', suppressLogs = false }) {
return new Promise(async (resolve, reject) => {
this.host = this._normalizeHost(host);
this.port = port;
Expand Down
2 changes: 1 addition & 1 deletion lib/tsconfig.build.tsbuildinfo

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/memphis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Memphis {
this.accountId = 1;
this.connectionToken = '';
this.reconnect = true;
this.maxReconnect = 10;
this.maxReconnect = -1;
this.reconnectIntervalMs = 1500;
this.timeoutMs = 15000;
this.brokerConnection = null;
Expand Down Expand Up @@ -150,7 +150,7 @@ class Memphis {
* @param {String} connectionToken - connection token.
* @param {String} password - depends on how Memphis deployed - default is connection token-based authentication
* @param {Boolean} reconnect - whether to do reconnect while connection is lost.
* @param {Number} maxReconnect - The reconnect attempts.
* @param {Number} maxReconnect - is the maximum number of reconnection attempts. The default value is -1 which means reconnect indefinitely.
* @param {Number} reconnectIntervalMs - Interval in miliseconds between reconnect attempts.
* @param {Number} timeoutMs - connection timeout in miliseconds.
* @param {string} keyFile - path to tls key file.
Expand All @@ -167,7 +167,7 @@ class Memphis {
connectionToken = '',
password = '',
reconnect = true,
maxReconnect = 10,
maxReconnect = -1,
reconnectIntervalMs = 1500,
timeoutMs = 2000,
keyFile = '',
Expand Down

0 comments on commit 9f161c7

Please sign in to comment.