node-red-contrib-questdb 0.6.25 → 0.6.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -273,9 +273,12 @@ module.exports = function (RED) {
273
273
  }
274
274
  });
275
275
 
276
- node.on('close', function (done) {
276
+ node.on('close', async function (done) {
277
277
  connection.emitter.removeListener('stateChange', stateChangeHandler);
278
278
  connection.users--;
279
+ if (connection.users <= 0) {
280
+ await connection.disconnect();
281
+ }
279
282
  done();
280
283
  });
281
284
  }
package/nodes/questdb.js CHANGED
@@ -163,7 +163,7 @@ module.exports = function (RED) {
163
163
  connectionState.sender = await Sender.fromConfig(connStr);
164
164
 
165
165
  // Wait for TCP transport to be fully ready
166
- await new Promise(resolve => setTimeout(resolve, 1000));
166
+ await new Promise(resolve => setTimeout(resolve, 5000));
167
167
 
168
168
  connectionState.updateState(true);
169
169
 
@@ -254,12 +254,9 @@ module.exports = function (RED) {
254
254
 
255
255
  configNode.on('close', async function (done) {
256
256
  const conn = connectionPool.get(connectionKey);
257
- if (conn) {
258
- conn.users--;
259
- if (conn.users <= 0) {
260
- await conn.disconnect();
261
- connectionPool.delete(connectionKey);
262
- }
257
+ if (conn && conn.users <= 0) {
258
+ await conn.disconnect();
259
+ connectionPool.delete(connectionKey);
263
260
  }
264
261
  done();
265
262
  });
@@ -631,10 +628,13 @@ module.exports = function (RED) {
631
628
  }
632
629
  });
633
630
 
634
- node.on('close', function (done) {
631
+ node.on('close', async function (done) {
635
632
  // Unsubscribe from state changes
636
633
  connection.emitter.removeListener('stateChange', stateChangeHandler);
637
634
  connection.users--;
635
+ if (connection.users <= 0) {
636
+ await connection.disconnect();
637
+ }
638
638
  done();
639
639
  });
640
640
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-questdb",
3
- "version": "0.6.25",
3
+ "version": "0.6.27",
4
4
  "description": "Node-RED nodes for writing high-performance time-series data to QuestDB using Influx Line Protocol (ILP). Supports IoT, industrial monitoring, smart buildings, fleet telematics, healthcare, agriculture, and more.",
5
5
  "author": {
6
6
  "name": "Holger Amort"