paulgrove / node-syslog-client Goto Github PK
View Code? Open in Web Editor NEWTCP and UDP syslog client RFC 3164 and 5424
TCP and UDP syslog client RFC 3164 and 5424
There have been no new releases since 1.1.1 and some of the documented features, such as TLS transport, don't work on 1.1.1
Similar code found in 1 other location (mass = 47)
https://codeclimate.com/github/paulgrove/node-syslog-client/index.js#issue_5811359537cdc70001000005
Hi -
Noticed that setting severity to 0 defaults to it being 6. However, setting severity to 8 somewhow
sets severity to 0.
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!
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...
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()
}
});
I cant find any log in /var/log/syslog. Please tell me the place to find the logs added.
I like this library alot but would like to know if there is someone maintaining it?
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.
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;
}`
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.
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.
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 ;-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.