node-nats-streaming-buffered-client
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -244,3 +244,3 @@ "use strict"; | ||
var currentConnection = _this.stan; | ||
currentConnection.on('disconnect', resolve); | ||
currentConnection.on('close', resolve); | ||
currentConnection.on('error', reject); | ||
@@ -314,3 +314,3 @@ currentConnection.close(); | ||
this.emit('forced_reconnected', this.stan); | ||
return [2 /*return*/]; | ||
return [2 /*return*/, this.stan]; | ||
} | ||
@@ -317,0 +317,0 @@ }); |
@@ -109,3 +109,3 @@ /// <reference types="node" /> | ||
*/ | ||
reconnect(): Promise<void>; | ||
reconnect(): Promise<nats.Stan | undefined>; | ||
/** | ||
@@ -112,0 +112,0 @@ * Push an item into the buffer to publish it |
{ | ||
"name": "node-nats-streaming-buffered-client", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -74,2 +74,20 @@ # NATS Streaming Buffered Client | ||
### Forced reconnects and subscriptions | ||
If the client loses connection with the nats streaming server long enough the server will decide to remove the client. | ||
The lower level nats layer will reconnect when a connection is restored but publishing will fail becuase the client is not known on the server. | ||
A forced reconnect will be triggered by the buffered client when this occurs. | ||
This will re-register the client with the server and publishing will resume. | ||
If you have also created subscriptions these will not resume receiving events because the subscription state will also have been purged on the server. | ||
The buffered client will emit a trio of events during a forced reconnect which can be used to resubscribe. | ||
These events are: | ||
- forced_reconnecting | ||
- forced_disconnected | ||
- forced_reconnected | ||
To prevent memory leaks be sure to call `removeAllListeners` on your old subscription(s). | ||
The `forced_reconnected` event is a good trigger to begin resubscribing. | ||
## NPM scripts | ||
@@ -76,0 +94,0 @@ |
Sorry, the diff of this file is not supported yet
39235
96