logstash-plugins / logstash-input-irc

Apache License 2.0
3 stars 16 forks source link

Plugin keeps reconnecting/crashing #25

Open lenisko opened 4 years ago

lenisko commented 4 years ago

output { elasticsearch { hosts => "localhost" index => "logstash-irc-%{+YYYY.MM.dd}" } }

- Sample Data:

Dec 21 04:27:01 saya logstash[26428]: [2019-12-21T04:27:01,808][ERROR][logstash.javapipeline ][main] A plugin had an unrecoverable error. Will restart this plugin. Dec 21 04:27:01 saya logstash[26428]: Pipeline_id:main Dec 21 04:27:01 saya logstash[26428]: Plugin: <LogStash::Inputs::Irc nick=>"xxx", channels=>["#xxx", "#xxx"], port=>6697, host=>"irc.pirc.pl", real=>"xxx", id=>"xxx", secure=>true, catch_all=>true, user=>"xxx", get_stats=>true, enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"xxx", enable_metric=>true, charset=>"UTF-8">, stats_interval=>5> Dec 21 04:27:01 saya logstash[26428]: Error: undefined method force_encoding' for nil:NilClass Dec 21 04:27:01 saya logstash[26428]: Exception: NoMethodError Dec 21 04:27:01 saya logstash[26428]: Stack: /usr/share/logstash/logstash-core/lib/logstash/util/charset.rb:13:inconvert' Dec 21 04:27:01 saya logstash[26428]: /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-codec-plain-3.0.6/lib/logstash/codecs/plain.rb:35:in decode' Dec 21 04:27:01 saya logstash[26428]: /usr/share/logstash/logstash-core/lib/logstash/codecs/delegator.rb:45:inblock in decode' Dec 21 04:27:01 saya logstash[26428]: org/logstash/instrument/metrics/AbstractSimpleMetricExt.java:45:in time' Dec 21 04:27:01 saya logstash[26428]: org/logstash/instrument/metrics/AbstractNamespacedMetricExt.java:44:intime' Dec 21 04:27:01 saya logstash[26428]: /usr/share/logstash/logstash-core/lib/logstash/codecs/delegator.rb:44:in decode' Dec 21 04:27:01 saya logstash[26428]: /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-irc-3.0.7/lib/logstash/inputs/irc.rb:146:inhandle_response' Dec 21 04:27:01 saya logstash[26428]: /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-irc-3.0.7/lib/logstash/inputs/irc.rb:117:in run' Dec 21 04:27:01 saya logstash[26428]: /usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:322:ininputworker' Dec 21 04:27:01 saya logstash[26428]: /usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:314:in `block in start_input'


- Steps to Reproduce:
1. Install plugin
2. Create new config inside `/etc/logstash/conf.d/` directory
3. Start `logstash`
4. Leave for a moment on active channels

- Other info:
Observed same situation as here https://discuss.elastic.co/t/logstash-irc-output-plugin-creates-new-irc-server-connections-on-reload/90293 after a while we have many stuck clients on channels.
acidvegas commented 1 year ago

The plugin seems to not be able to decode certain character sets on IRC. Ill see if I can get a PR to fix this soon.

This error is triggered because somewhere in the Logstash process, the program is trying to call the method force_encoding on an object that is nil. In Ruby, you can't call methods that are intended for a string on a nil value.

Looking at the stack trace, it appears that this error is originating from the IRC input plugin for Logstash. When the decode method is called in the plain codec, it appears to be passing a nil value, leading to the error.

lenisko commented 1 year ago

Nice to see some attention on 3-year-old issue ;-) thanks for great go through and good luck!