Socket
Socket
Sign inDemoInstall

log4js-logstash-tcp

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log4js-logstash-tcp - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

38

classes/TcpConnectionPool.js

@@ -6,9 +6,12 @@ "use strict";

const MAX_TCP_CONNECITONS = 300;
const DEFAULT_MAX_TCP_CONNECTIONS = 300;
class TcpConnectionWrapper extends EventEmitter {
constructor(host, port) {
constructor(host, port, config) {
super();
this.connectionNotReadyRetryInterval = parseInt(config.connectionNotReadyRetryInterval || 500);
this.connectionTimeout = parseInt(config.connectionTimeout || 5000);
const self = this;

@@ -22,7 +25,7 @@ this.connection = net.connect({

this.connection.setTimeout(5000);
this.connection.setTimeout(this.connectionTimeout);
this.connection.on("timeout", () => {self.destroy()});
this.connection.on("close", () => {self.destroy()});
this.connection.on("error", (err) => {
console.error(`Error with the connection to ${host}:${port}. ${err}`);
console.error(`logstash Error with the connection to ${host}:${port}. ${err}`);
// From docs: "The close event will be called just after this one

@@ -41,5 +44,14 @@ });

this.connection.write(message)
this.realSend(message);
}
realSend(message) {
const self = this;
if(this.connected === true) {
this.connection.write(message)
} else {
setTimeout(() => {self.realSend(message);}, this.connectionNotReadyRetryInterval);
}
}
destroy() {

@@ -56,5 +68,11 @@ this.connection.end();

constructor() {
constructor(config) {
this.tcpConnections = {}
if(config) this.config = config;
else this.config = {};
if(!this.config.maxTcpConnections) {
this.config.maxTcpConnections = DEFAULT_MAX_TCP_CONNECTIONS;
}
}

@@ -67,3 +85,3 @@

_getTcpConnection(host, port) {
const index = TcpConnectionPool._createIndexForTcpConnection();
const index = this._createIndexForTcpConnection();
return this.tcpConnections[index] || this._createTcpConnection(index, host, port);

@@ -74,3 +92,3 @@ }

const self = this;
const tcpConnectionWrapper = new TcpConnectionWrapper(host, port);
const tcpConnectionWrapper = new TcpConnectionWrapper(host, port, this.config);
this.tcpConnections[index] = tcpConnectionWrapper;

@@ -85,4 +103,4 @@

static _createIndexForTcpConnection() {
return Math.floor( Math.random() * MAX_TCP_CONNECITONS) % MAX_TCP_CONNECITONS;
_createIndexForTcpConnection() {
return Math.floor( Math.random() * this.config.maxTcpConnections) % this.config.maxTcpConnections;
}

@@ -89,0 +107,0 @@

{
"name": "log4js-logstash-tcp",
"version": "1.0.7",
"version": "1.0.8",
"author": "Aigent B.V.",

@@ -5,0 +5,0 @@ "description": "This is a copy of the logstashUDP appender but instead sending via UDP send via TCP to avoid the maximum 64k bytes message size with the logstashUDP appender.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc