Stream and write tcp-log-server entries. Reconnect automatically.
var TCPLogClient = require('tcp-log-client')
var client = new TCPLogClient({
server: {port: port},
keepAlive: true,
noDelay: true,
from: 1,
reconnect: {failAfter: 5}
})
.on('error', function (error) {
console.error(error)
})
.on('fail', function () {
console.error('Failed to reconnect.')
})
.once('ready', function () {
if (client.connected) {
client.write({example: 'entry'}, function (error, index) {
console.log('New entry index is %d', index)
client.destroy()
})
}
})
client.readStream.on('data', function (chunk) {
console.log(chunk.index)
console.log(chunk.entry)
})
See also: