fluent / fluent/fluent-logger-node

Queue Message until Reconnection Complete

Open
#93 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
258
Forks
82
PR merge metrics
No merged PRs in 30d

Description

I am using fluent-logger-node in a docker swarm environment which is to say the cluster of services operates within their own private network and I have one node service communicating to fluentd container within this internal network.

The problem I face in all socket situations (e.g. database connections) is that sockets seem to close after a period of time that only becomes evident to the service after a failed connection attempt, I assume it's a docker swarm problem but that's beside the point. The error as output to me when this socket close occurs is an ECONNRESET error. Which I have learned translates to the other side of the TCP conversation abruptly closed.

In the case of the pooled db connections I have access to the socket object and enable the keepAlive setting to all pools, but even if I forked this repo and exposed the socket I don't want to have to utilise this technique. Rather it would seem more elegant to queue emitted messages until a reconnection is established,

I've looked to the `.on` error event which I would assume would trigger in the event of a failed connection, but I don't think it would be sensible to bind an error event to every message I emit as I don't seem to have the capacity to turn those events off on a success callback.

Also, does the callback arg in `emit` method pass an error message in the event of an err? Or does the callback just fire regardless of message success and provide no value?

I was also thinking of setting the timeout to be something short and frequent so that the socket gets refreshed regularly before the docker swarm network shuts the socket but I had the value to 3.0 initially and my emits would still be hit with an ECONNRESET.

Any advice?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the emit method, its callback behavior, and the .on error handling described in the issue. Trace how reconnection and the timeout are handled. Done should be defined as a clear behavior for messages emitted during ECONNRESET, including whether they are queued until reconnection and how delivery errors reach callers.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.