Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winston containers problem with winston-syslog and solution #208

Open
GreenHex opened this issue Sep 19, 2022 · 2 comments
Open

Winston containers problem with winston-syslog and solution #208

GreenHex opened this issue Sep 19, 2022 · 2 comments

Comments

@GreenHex
Copy link

GreenHex commented Sep 19, 2022

The Problem

When creating multiple loggers with winston.loggers.add('id', params) to create loggers in containers, winston-syslog doesn't log, other than for the primary process when protocol is set to udp4 (it works with tcp4). This is on Node.js v16.14.0 on Windows 10.

Potential Solution

Set this.socket.bind() to this.socket.bind({ port: 0, exclusive: true }) around line 323 of winston-syslog.js.

Apparently not a problem in Linux. This, despite node.js documentation mentioning, "When exclusive is true, however, the handle is not shared and attempted port sharing results in an error."

@GreenHex GreenHex changed the title Winston containers problem and solution with winston-syslog Winston containers problem with winston-syslog and solution Sep 19, 2022
@DABH
Copy link
Contributor

DABH commented Sep 20, 2022

We don't have enough active contributors on the project to investigate theses kinds of issues unfortunately, but PRs from the community are welcomed and will be reviewed.

I'm curious what this.socket.bind({ port: 0, exclusive: true }) does, compared to this.socket.bind() (I have not looked at this code in ages and don't know the details of the API). I wonder if that would break any use cases or expected behavior. It's also weird that the problematic behavior you report seems so specific (Windows + udp4) -- would be good to maybe understand that a bit better.

@GreenHex
Copy link
Author

Unfortunately, I don't have a deeper insight into what is happening in this case. After struggling for days trying to trace the problem, and then deciding to write a logger myself, the solution was just a guess - that workers were not forwarding the logging request to the parent, and the solution was to route the request or to broadcast to all ports.

I will continue to look into this, and let you know, as the solution does not appear efficient. I myself am baffled by the 'exclusive' parameter, which works counterintuitively. Maybe all worker processes are trying to bind to a single port, and failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants