Gathering detailed insights and metrics for node-nats-streaming-buffered-client
Gathering detailed insights and metrics for node-nats-streaming-buffered-client
Gathering detailed insights and metrics for node-nats-streaming-buffered-client
Gathering detailed insights and metrics for node-nats-streaming-buffered-client
Buffered client for NATS node.js client
npm install node-nats-streaming-buffered-client
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (85.43%)
JavaScript (14.57%)
Total Downloads
6,149
Last Day
7
Last Week
71
Last Month
102
Last Year
741
MIT License
1 Stars
83 Commits
1 Forks
3 Watchers
20 Branches
2 Contributors
Updated on Jun 09, 2021
Latest Version
1.6.0
Package Id
node-nats-streaming-buffered-client@1.6.0
Unpacked Size
43.21 kB
Size
11.05 kB
File Count
6
NPM Version
6.9.0
Node Version
8.9.1
Cumulative downloads
Total Downloads
Last Day
250%
7
Compared to previous day
Last Week
3,450%
71
Compared to previous week
Last Month
24.4%
102
Compared to previous month
Last Year
106.4%
741
Compared to previous year
1
1
29
This is a client for the NATS streaming server built for clients that may have an intermittent connection to the server. The need for this client arose for IoT devices with 4G connections and to ensure no messages are lost on server upgrades, reboots or mishaps.
1npm install node-nats-streaming-buffered-client
You can import the buffered client class after installing it with npm:
1import { NatsBufferedClient } from 'node-nats-streaming-buffered-client' 2 3// Initialize a client with a buffer of 2000 messages 4// The default reconnect timeout is 30s but can be changed 5// 6// You can instruct the client to wait for the initial connect to succeed before 7// allowing any kind of publishing. 8// 9// You can also provide an alternate logger if you want to use something 10// like bunyan. The same interface as console is asumed 11// 12const bufferSize = 2000; 13const waitForInitialConnect = false; 14const logger = console; 15 16// NOTE: constructor parameters have changed in v0.3.0 17// 18const client = new NatsBufferedClient( bufferSize, waitForInitialConnect, logger ); 19 20// Connect to the NATS server 21// NATS connect options: https://github.com/nats-io/node-nats#connect-options 22// 23const natsOptions = { ... }; 24client.connect( 'test-cluster', 'test', natsOptions ); 25 26// Add a message to the buffer for publishing 27// 28client.publish( 'my-channel', { content: 'stuff' } ); 29 30// Access to NATS Streaming client instance is available 31// 32const subscription = client.stan.subscribe( 'topic', ... );
There is a more complete test client here
The reconnect logic from the nats streaming client relies on these 3 options:
1const defaultOptions = { 2 maxReconnectAttempts: -1, 3 reconnect: true, 4 waitOnFirstConnect: true, 5};
Be very careful when supplying your own connect options to not change these unless you know what you're doing.
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:
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 run test
: Run test suitenpm run build
: Generate bundles and typings, create docsNo vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
74 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More