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

Error in Netty pipeline: java.io.IOException: Connection reset by peer #132

Open
damm opened this issue Nov 30, 2018 · 28 comments
Open

Error in Netty pipeline: java.io.IOException: Connection reset by peer #132

damm opened this issue Nov 30, 2018 · 28 comments

Comments

@damm
Copy link

damm commented Nov 30, 2018

For all general issues, please provide the following details for fast resolution:

  • Version: 5.2.0
  • Operating System: Ubuntu / Linux
  • Config File
  tcp {
    port => '514'
    add_field => { "service" => 'syslog' }
  }
  • Sample Data:
    I don't know if this matters. It wasn't dropping data.
  • Steps to Reproduce:

Configure Logstash to listen on TCP on port 514

  tcp {
    port => '514'
    add_field => { "service" => 'syslog' }
  }
  • Steps to resolve the problem:

Updating Gemfile.lock to pin it to the 5.1.0 release and then running logstash-plugin install --version 5.1.0 logstash-input-tcp

Lastly, I enabled debug mode and I didn't see anything more. There is no stack trace of anything crashing in the logs. It just returns this error for every time a syslog event is received. No data is lost.

@jsvd
Copy link
Member

jsvd commented Nov 30, 2018

I can't seem to reproduce this:

 /tmp/logstash-6.5.1 % bin/logstash -e "input { tcp { port => 3333 } }"
Sending Logstash logs to /tmp/logstash-6.5.1/logs which is now configured via log4j2.properties
[2018-11-30T09:02:11,522][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.queue", :path=>"/tmp/logstash-6.5.1/data/queue"}
[2018-11-30T09:02:11,531][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.dead_letter_queue", :path=>"/tmp/logstash-6.5.1/data/dead_letter_queue"}
[2018-11-30T09:02:11,623][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2018-11-30T09:02:11,637][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"6.5.1"}
[2018-11-30T09:02:11,656][INFO ][logstash.agent           ] No persistent UUID file found. Generating new UUID {:uuid=>"6b6225e0-daae-46dd-96d8-876b3df0ed8b", :path=>"/tmp/logstash-6.5.1/data/uuid"}
[2018-11-30T09:02:14,324][INFO ][logstash.pipeline        ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>8, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}
[2018-11-30T09:02:14,392][INFO ][logstash.inputs.tcp      ] Starting tcp input listener {:address=>"0.0.0.0:3333", :ssl_enable=>"false"}
[2018-11-30T09:02:14,651][INFO ][logstash.pipeline        ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x1860b4c2 run>"}
[2018-11-30T09:02:14,682][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2018-11-30T09:02:14,844][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
{
       "message" => "test",
          "port" => 59612,
      "@version" => "1",
    "@timestamp" => 2018-11-30T09:02:44.323Z,
          "host" => "localhost"
}

after running: echo test | nc localhost 3333

Can you also see this when binding a port higher than 514? Also, if you send data manually does it also reset? (e.g. echo test | nc host 514)

@damm
Copy link
Author

damm commented Dec 1, 2018

This is a container; I don't imagine that makes much of a difference. It's running as Root (ugh) however I don't think that's a problem.

There is this also in the startup log

[2018-11-30T01:59:26,330][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `<<' for nil:NilClass
[2018-11-30T01:59:26,340][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `<<' for nil:NilClass
[2018-11-30T01:59:26,541][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `<<' for nil:NilClass
[2018-11-30T01:59:26,620][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `<<' for nil:NilClass

Rebuilding the docker image that << for nil:NilClass goes away.

It may not actually be an error; it maybe how rsyslog is handling the TCP syslog. I wasn't able to prove that I was loosing data.

Using your example I can see it works fine; I guess I need to deploy my logstash image elsewhere and see if it fails the same way.

I tried to increase the debug level to get more data from logstash for the input-tcp plugin but I don't seem to get any more data?

Thanks

@jsvd
Copy link
Member

jsvd commented Dec 4, 2018

I've been trying to replicate with no success with docker with:

% docker run -p 5514:5514 --rm -it -v /tmp/logstash.conf:/usr/share/logstash/pipeline/logstash.conf:ro docker.elastic.co/logstash/logstash:6.5.1  

That undefined method <<' for nil:NilClass` does worry me though..

@cdenneen
Copy link

cdenneen commented Dec 14, 2018

Having same problem:

[2018-12-07T14:50:58,913][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2018-12-07T14:56:32,583][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T14:58:40,357][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:03:40,992][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:08:37,487][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:13:42,307][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:18:41,167][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:23:45,117][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:28:44,366][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:33:40,326][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:33:47,591][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:38:41,077][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:43:46,196][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:48:42,946][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:53:45,117][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T15:58:41,792][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:03:44,428][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:08:42,198][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:13:42,994][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:13:45,233][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:18:44,893][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:23:45,619][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:28:45,359][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2018-12-07T16:33:50,713][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer

This actually breaks that entire instance... I've tried to separate into it's own pipeline but still breaks the rest of the running instance. So along with few tcp inputs I have an sqs input that stops being read. Only way to fix is restart. Before now my only solution to not break everything was to create a second instance for just this input since a dedicated pipeline didn't work. Attempting now to downgrade to 5.1.0 as a solution and then possibly can go back to single instance with multiple pipelines.

I'm not running inside a container so possibly the undefined method equates to this when running on vm?

@damm
Copy link
Author

damm commented Dec 15, 2018

@cdenneen Ensure you modify Gemfile.lock to point to version 5.1.0 before you attempt to run logstash-plugin

for me I drop in a modified Gemfile.lock that handles this or else logstash-plugin won't let me downgrade.

ADD Gemfile.lock /opt/logstash/Gemfile.lock

Look for this line

    logstash-input-tcp (5.2.0-java)

change it to this

    logstash-input-tcp (5.1.0-java)

Then run

bin/logstash-plugin install --version 5.1.0 logstash-input-tcp

I guess I got lucky when things were still working..

@jsvd
Copy link
Member

jsvd commented Jan 8, 2019

This seems related to #136, continuing investigation.
For the folks hitting this, is the throughput high or low (i.e. could the plugin be timing out connections and behaving badly because of that?)

@eht16
Copy link

eht16 commented Feb 17, 2019

Suffering from the same issue here.

For me it happens quickly after starting up so I doubt about timeouts.
But the throughput might be somewhat higher (whatever this exactly means) as usually after restarting Logstash sending clients will repush their queued events to Logstash.

jsvd added a commit that referenced this issue Mar 9, 2019
currently the socket was being opened during `register` but the queue is only set during `run`, which mean that connections+data could arrive before the a queue was configured, causing the error seen in the linked issue.

This commit changes the socket opening to also happen during `run`.
Also fixes testing now that bind happens during `run`.

solves #132
jsvd added a commit that referenced this issue Mar 9, 2019
currently the socket was being opened during `register` but the queue is only set during `run`, which mean that connections+data could arrive before the a queue was configured, causing the error seen in the linked issue.

This commit changes the socket opening to also happen during `run`.
Also fixes testing now that bind happens during `run`.

solves #132
@jsvd
Copy link
Member

jsvd commented Mar 9, 2019

Hi folks, can you try updating the tcp plugin to 5.2.2 ? #142 should fix this

@damm
Copy link
Author

damm commented Mar 12, 2019

Hi @jsvd unfortunately it seems syslog entries are coming in however Logstash is flooding the docker logs with the same error:

[2019-03-12T03:13:09,979][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer

I'll have to track down which clients are failing; however I'm going to roll back to 5.1.0 until I have more time to do that.

@jsvd
Copy link
Member

jsvd commented Mar 12, 2019

Thank you for the feedback @damm, was this test with latest logstash + 5.2.2 plugin update?

I'll work on adding logic to know where this is coming from.

@damm
Copy link
Author

damm commented Mar 12, 2019

@jsvd correct that was the latest logstash + 5.2.2 plugin update.

@eapugo
Copy link

eapugo commented Apr 8, 2019

Also seems post this plugin update...the metrics on the tcp input fail to update despite the connection still up.

@musabqamri123
Copy link

musabqamri123 commented May 16, 2019

facing same issues with latest logstash ..... getting the same error periodically 5-10 min
[ERROR][logstash.inputs.tcp ] Error in Netty pipeline: java.io.IOException: Connection reset by peer

@mrichar1
Copy link

Seeing the same issue using logstash-input-tcp 6.0.3 having upgraded from 6.2.0 to 7.3.0 - have tried downgrading to various versions back to 5.2.2 without any success.

Getting the error on several different inputs from different clients/apps, each sending different data, so it doesn't appear to be client-side.

@mrichar1
Copy link

OK - made some progress... when logstash starts I see the following i the logs:

Automatically switching from json to json_lines codec {:plugin=>"tcp"} (not sure why this is the case).

If I add the default delimiter (\n) onto my json messages, then it seems to work fine - without them I get the connection reset error.

Can't find any info on how to force logstash not to switch out the codecs though...

@Kerwood
Copy link

Kerwood commented Nov 14, 2019

Any progress on this ?
My Logstash is flooding its logs with:

[2019-11-14T01:21:47,338][ERROR][logstash.inputs.tcp      ] Error in Netty pipeline: java.io.IOException: Connection reset by peer

@cdenneen
Copy link

Seems like just what we have to deal with:

{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573762039873,"thread":"nioEventLoopGroup-2-12","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573762341514,"thread":"nioEventLoopGroup-2-10","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573762647274,"thread":"nioEventLoopGroup-2-7","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573762948766,"thread":"nioEventLoopGroup-2-5","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573763253116,"thread":"nioEventLoopGroup-2-3","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573763557986,"thread":"nioEventLoopGroup-2-1","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573763861272,"thread":"nioEventLoopGroup-2-15","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573764163122,"thread":"nioEventLoopGroup-2-12","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573764465018,"thread":"nioEventLoopGroup-2-10","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}
{"level":"ERROR","loggerName":"logstash.inputs.tcp","timeMillis":1573764767669,"thread":"nioEventLoopGroup-2-7","logEvent":{"message":"Error in Netty pipeline: java.io.IOException: Connection reset by peer"}}

@ld57
Copy link

ld57 commented Nov 27, 2019

Hi,

I have also the same log messages.
using tcp plugin 5.2.3.

I had no problem with version 5.0.7, when i was on logstash 6.2.3

should this version (5.0.7) could be compatible with LS 7.x ?

@damm
Copy link
Author

damm commented Nov 27, 2019

@ld57 I use 5.1.0 on LS 7.4.0 so you should be fine.

Very thankful I can still backport this gem in Logstash to fix it 👍

@ld57
Copy link

ld57 commented Nov 28, 2019

going to downgrade the plugin on my 6.8.4 , to see the result

@ld57
Copy link

ld57 commented Nov 28, 2019

ok, I confirm, i downgraded the plugin to 5.0.7 and no more the message.
I remember that we had the same message in the 5.0.3 version, long time ago

@willemdh
Copy link

Also seeing this on Logstash 7.6.2 with all plugins updated to the latest version:

[logstash.inputs.tcp ] Error in Netty pipeline: java.io.IOException: Connection reset by peer

@9r00t-z
Copy link

9r00t-z commented Jul 30, 2020

Is there any update on this?

@RizeAllard
Copy link

Hi,

I also have this issue on my Logstash. I'm using version 7.8 and receiving the same error message:
[ERROR][logstash.inputs.tcp ][nxlog_input][02bs52c82b7b60de4344f01462751584ecee8538d980926e2bf9f329cfc4c7f4] Error in Netty pipeline: java.io.IOException: Connection reset by peer

I am using nxlog to collect logs from hosts, because filebeat was not working on them correctly. Is there any proper working solution for this issue?

@LeUser111
Copy link

LeUser111 commented Aug 21, 2020

Running into the same issue with a fresh installation of Logstash 7.9.0 OSS on Oracle Linux 7.

[2020-08-21T07:27:21,455][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2020-08-21T07:27:23,157][INFO ][org.reflections.Reflections] Reflections took 36 ms to scan 1 urls, producing 22 keys and 45 values 
[2020-08-21T07:27:24,774][INFO ][logstash.outputs.elasticsearch][main] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://localhost:9200/]}}
[2020-08-21T07:27:25,005][WARN ][logstash.outputs.elasticsearch][main] Restored connection to ES instance {:url=>"http://localhost:9200/"}
[2020-08-21T07:27:25,060][INFO ][logstash.outputs.elasticsearch][main] ES Output version determined {:es_version=>7}
[2020-08-21T07:27:25,064][WARN ][logstash.outputs.elasticsearch][main] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>7}
[2020-08-21T07:27:25,193][INFO ][logstash.outputs.elasticsearch][main] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//localhost:9200"]}
[2020-08-21T07:27:25,292][INFO ][logstash.outputs.elasticsearch][main] Using a default mapping template {:es_version=>7, :ecs_compatibility=>:disabled}
[2020-08-21T07:27:25,362][INFO ][logstash.javapipeline    ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>4, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>500, "pipeline.sources"=>["/opt/elasticstack/conf/logstash/logstash.conf"], :thread=>"#<Thread:0x408b2b77 run>"}
[2020-08-21T07:27:25,400][INFO ][logstash.outputs.elasticsearch][main] Index Lifecycle Management is set to 'auto', but will be disabled - Index Lifecycle management is not installed on your Elasticsearch cluster
[2020-08-21T07:27:25,404][INFO ][logstash.outputs.elasticsearch][main] Attempting to install template {:manage_template=>{"index_patterns"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s", "number_of_shards"=>1}, "mappings"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}}
[2020-08-21T07:27:26,253][INFO ][logstash.javapipeline    ][main] Pipeline Java execution initialization time {"seconds"=>0.89}
[2020-08-21T07:27:26,446][INFO ][logstash.javapipeline    ][main] Pipeline started {"pipeline.id"=>"main"}
[2020-08-21T07:27:26,469][INFO ][logstash.inputs.tcp      ][main][0d6b089cb743eea97cd7ced5413913147d02e770240bc80152a0a4e6df17e9e0] Starting tcp input listener {:address=>"0.0.0.0:4560", :ssl_enable=>"false"}
[2020-08-21T07:27:26,648][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2020-08-21T07:27:27,127][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2020-08-21T07:30:43,653][ERROR][logstash.inputs.tcp      ][main][0d6b089cb743eea97cd7ced5413913147d02e770240bc80152a0a4e6df17e9e0] Error in Netty pipeline: java.io.IOException: Connection reset by peer
[2020-08-21T07:31:13,902][ERROR][logstash.inputs.tcp      ][main][0d6b089cb743eea97cd7ced5413913147d02e770240bc80152a0a4e6df17e9e0] Error in Netty pipeline: java.io.IOException: Connection reset by peer

Here is the pipeline configuration:

  stdin { } 
  tcp {
    port => 4560 
    codec => json_lines   
  }
}
output {
  elasticsearch { 
    hosts => ["localhost:9200"]
    index => "logstash001" 
  }
}

As others have pointed out, no logs seem to be dropped.

Also I'm currently running the system with very, very low activity. Like one log message every few minutes. I have three hosts currently sending logs (none in the last ten minutes), however in the last five minutes alone I've had 20 connection reset messages...

@chenhao1893
Copy link

Gentlemen, may I ask who has seen this mistake?

[the 2020-12-08 T08:03:36, 876] [ERROR] [TCP] logstash. Inputs. [the main] [f423a74972b728c3569e569362d4c9ecc8568132f65a4afcf5380f842d77dfae] ERROR in Netty pipeline. Org. App. Exceptions. IOError: (IOError) IOError

Logstash received logs cannot be written in ElasticSearch, please report the errors described above. Please kindly help, thank you!

@snimesh
Copy link

snimesh commented Dec 11, 2020

Resolved: We had the same issue. Same error message. Hundreds of them every day. We involved the F5 network engineer. She found in F5 logs Idle timeout messages. She changed the idle timeout on F5 from 5 minutes to 25 minutes. That stopped the errors from appearing in the logs These were warning messages and never really caused any data loss.

@kingnarmer
Copy link

kingnarmer commented Aug 14, 2023

I am running into same situation . Appreciate help remediating issue.

All my source IPs are on same subnet. No firewall between log sources and logstash backend. I am running logstash 8.9.0

I added tcp_keep_alive on source and destination logstash without success.

logs path ( k8s clusters fluentd ---> logstash ---> ELK)

logstash input section

input {
      tcp {
        codec => fluent
        port => 7000
        tcp_keep_alive => 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