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

Not working using TCP #11

Open
1 task done
cmanzur opened this issue May 5, 2021 · 2 comments
Open
1 task done

Not working using TCP #11

cmanzur opened this issue May 5, 2021 · 2 comments

Comments

@cmanzur
Copy link

cmanzur commented May 5, 2021

Prerequisites

Description

I'm using the same example at the readme. It works with UDP. Using UDP it hangs.

Steps to Reproduce

  1. Run logstash with the same configuration at the official README.md
input {
  tcp {
    codec => json
    port => 28777
  }
}
  1. Run nodejs using the same example BUT using TCP:
const Winston = require('winston');
const WinstonLogStash = require('winston3-logstash-transport');

const logger = Winston.createLogger();

logger.add(new WinstonLogStash({
  mode: 'tcp',
  host: '127.0.0.1',
  port: 28777
}));

logger.error('Some Error');

Expected behavior:

The log must appear in elasticsearch and the node process must end.

Actual behavior:

The node process never ends. The log doesn't appear in ES.
The process hangs. If I manually finalize the process using ctrl+C, then it stops and the log appears in ES.

Reproduces how often:

Always

Versions

  • Docker docker.elastic.co/logstash/logstash-oss:7.10.2
  • Docker nodejs:14.15.4-alpine3.10
  • Dependencies:
    -- winston 3.3.3
    -- winston3-logstash-transport 1.2.3

Additional Information

If I run logstash using UDP and winston using mode: 'udp' it works. But I want TCP mode.

@LuanaMartelli
Copy link

Hello,

This issue may be quite old, but I ran into the same problem.
Looking at the code and thanks to this answer on Stackoverflow, I change the line 133 in file index.js to
this.socket.write(message + '\n', undefined, callback);
and this fixed the problem for TCP.

Hope it helps for further uses.
Cheers.

@fauzanelka
Copy link

Rather than directly modifying the library. For now, you could actually use the option trailingLineFeed to true.

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

3 participants