Coder Social home page Coder Social logo

node-syslog-client's People

Contributors

cdscott avatar dependabot[bot] avatar guimard avatar helorem avatar jeremybernier avatar manni83 avatar mividtim avatar paulgrove avatar sethb0 avatar stephenwvickers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-syslog-client's Issues

"connection timed out" Issues

It seems that when starting a TCP connection, to send log entries only, that a "connection timed out" error is always sent at least once. Continuing syslog events send fine.

It appears that there needs to be some function to "clear" the timeout event, or change how timeouts are handled?

Thank you!

log method does not catch ECONNREFUSED or ECONNRESET

I have an async function that returns a promise.

When the hostname or port number is incorrect, it returns the error correctly. However, when it is a connection based issue, it does not seem to return anything thus resulting in a success.

Some quick generic code below.

  `const syslog = syslog.createClient("hostname", createOptions);

        await new Promise<void>((resolve, reject) => {
             syslog.log("msg", logOptions, (err) => {
                 if (err) {
                     logger.error(`Failed to send to syslog server: ${err}`);
                     syslogLogger.close();
                     reject(err);
                     return;
                 } else {
                     logger.info("Sent event to syslog server...");
                     syslogLogger.close();
                     return resolve();
                 }
             });
     });

     return;
}`

Variable `key` in `_expandConstantObject()` missing `var` declaration

In _expandConstantObject() there is a "var" missing here:

for (key in object)
    keys.push(key);

This ought to be changed, so that "key" does not become a global variable:

for (var key in object)
    keys.push(key);

Tiny change -- I didn't want to wrap this into a pull request ;-)

(UDP) client.close() in log callback prevents message send.

When using UDP transport, calling client.close() from within the client.log callback function prevents the message from being sent. This appears to be a result of the client.log callback function being called synchronously in index.js, line 174, rather than from within the transport's async send function callback after the send occurs. This could be issue for TCP too, but definitely reproducible with UDP.

Cb not a function on client

I have this client built and getting an error stating "cb" is not a function.

client.log(message, function(error) {
                        if (error) {
                            console.error(error);
                        } else {
                            console.log("sent message successfully");
                            callback()
                        }
                    });

Severity 0 defaults to 6

Hi -

Noticed that setting severity to 0 defaults to it being 6. However, setting severity to 8 somewhow
sets severity to 0.

Is it possible to send a response back from server to syslog-client?

I have been trying to communicate between the syslog-client with Tcp transport and tcp-server. Communication between the syslog-client to tcp-server works well . I doubted the syslog-client doesn't provide the other way around like receiving a response data from tcp-server.

Tcp-sever:

    var net             = require('net');
    
    var server = net.createServer((socket) => {

    console.log('Received connection');

    socket.setEncoding('utf8');
    
    socket.on('data', function(data) {
        console.log('Socket recieved data');
        console.log(data);
        var ack = {
            type: 'hello_ack',
            data: {}
        };
           // Sending an acknowledge to syslog-client
    	socket.write(JSON.stringify(ack) + '\n');
	});

  }).on('error', (err) => {
 throw err;
 }).on('connection',function(data){
console.log("connection in establish");
})

server.listen(54764,() => {
     var address = server.address();
     console.log('opened server on %j', address);
});

Tcp-Syslog-client:

var syslog = require("syslog-client");
var os = require('os');

var options = {
    syslogHostname: os.hostname(),
    transport: syslog.Transport.Tcp,
    port:54764
};
var client = syslog.createClient("127.0.0.1", options);
var opts = {
    facility: syslog.Facility.Alert,
    severity: syslog.Severity.Critical,
    severityCode: 2,
    tag: 'error',
    hostname:os.hostname()
};

client.log("hello" , opts, function(error){
   if (error) {
      console.error(error);
    } else {
      console.log("sent message successfully");
    }
});

// Expect the server socket write data available at here
client.on("data", function(data){
  console.log("data received back ===> ", data);
});

client.on("error", function(data){
  console.log(data," === error ===");
});

The "hello" message is successfully passed from syslog-client to tcp-server works fine. But the response from tcp-server to syslog-client doesn't happen. I am not sure probably whether I missed something in responding at tcp-server or receiving at syslog-client.

I would like to know the syslog-client have the capability of sending and receiving data in Tcp transport mode.

connection timed out

I am using syslog client and when I debug I get this error.

events.js:377
throw er; // Unhandled 'error' event
^

Error: connection timed out
at Socket. (C:\xxx\Kinvey-To-ADX\node_modules\syslog-client\index.js:276:14)
at Object.onceWrapper (events.js:519:28)
at Socket.emit (events.js:400:28)
at Socket._onTimeout (net.js:495:8)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7)
Emitted 'error' event on Client instance at:
at Socket. (C:\xxx\Kinvey-To-ADX\node_modules\syslog-client\index.js:277:7)
at Object.onceWrapper (events.js:519:28)
[... lines matching original stack trace ...]
at processTimers (internal/timers.js:500:7)
[nodemon] app crashed - waiting for file changes before starting...

Error: getaddrinfo ENOTFOUND when specifying a hostname instead an IP

If found that when using the client with hostname: const client = syslog.createClient('my.host.name.here', options); I get an Error: getaddrinfo ENOTFOUND ... error.

I found the problem is related with the way code chose the family IP at line: https://github.com/paulgrove/node-syslog-client/blob/master/index.js#L195

That makes that a non IP (like a hostname) be considered a IPv6.

The problem can be easily fixed changing:

var af = net.isIPv4(this.target) ? 4 : 6;

by

var af = net.isIPv6(this.target) ? 6 : 4;

This issue is important for me. Could you fix and publish a new npm package?
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.