# Listen loop error: IOError: closed stream

**URL:** <https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083>\
**Category:** Logstash\
**Created:** [April 6, 2018, 11:37am UTC](https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083 "2018-04-06T11:37:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hzarrabi](https://avatars.discourse-cdn.com/v4/letter/h/f9ae1b/32.png) [@hzarrabi](https://discuss.elastic.co/u/hzarrabi)\
**Post date:** [April 6, 2018, 11:37am UTC](https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083/1 "2018-04-06T11:37:20Z")

</div>

Hi,

When I start the logstash as a service, I receive the folowing error.  
I have set the pipeline.yml with a single entry as a conf file. at the same time when I start the logstash in commande line, it run correctly and starts to index in elasticsearch.

Any help is appreciated.

```
[2018-04-06T12:54:47,962][FATAL][logstash.runner] An unexpected error occurred! {:error=>#<NameError: undefined local variable or method `dotfile' for #<AwesomePrint::Inspector:0xa953a4f>
Did you mean? @@dotfile>, :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/awesome_print-1.8.0/lib/awesome_print/inspector.rb:163:in `merge_custom_defaults!'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/awesome_print-1.8.0/lib/awesome_print/inspector.rb:50:in `initialize'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/kernel.rb:9:in `ai'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-codec-rubydebug-3.0.5/lib/logstash/codecs/rubydebug.rb:39:in `encode_default'", "org/jruby/RubyMethod.java:115:in `call'", "/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-codec-rubydebug-3.0.5/lib/logstash/codecs/rubydebug.rb:35:in `encode'", "/usr/share/logstash/logstash-core/lib/logstash/codecs/base.rb:50:in `block in multi_encode'", "org/jruby/RubyArray.java:1734:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/codecs/base.rb:50:in `multi_encode'", "/usr/share/logstash/logstash-core/lib/logstash/outputs/base.rb:90:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/single.rb:15:in `block in multi_receive'", "org/jruby/ext/thread/Mutex.java:148:in `synchronize'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/single.rb:14:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/output_delegator.rb:49:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:479:in `block in output_batch'", "org/jruby/RubyHash.java:1343:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:478:in `output_batch'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:430:in `worker_loop'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:385:in `block in start_workers'"]}
[2018-04-06T12:54:48,048][DEBUG][logstash.agent] 2018-04-06 12:54:48 +0200: Listen loop error: java.nio.channels.ClosedSelectorException
[2018-04-06T12:54:48,049][DEBUG][logstash.agent] sun.nio.ch.SelectorImpl.keys(SelectorImpl.java:68)
org.jruby.util.io.SelectorPool.put(SelectorPool.java:88)
org.jruby.util.io.SelectExecutor.selectEnd(SelectExecutor.java:59)
org.jruby.util.io.SelectExecutor.go(SelectExecutor.java:44)
org.jruby.RubyIO.select(RubyIO.java:3405)
org.jruby.RubyIO$INVOKER$s$0$3$select.call(RubyIO$INVOKER$s$0$3$select.gen)
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:721)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:200)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:338)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:314)
org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:73)
org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:77)
org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:144)
org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:130)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:192)
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:318)
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:131)
org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:339)
org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:73)
org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:148)
org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:73)
org.jruby.runtime.Block.call(Block.java:124)
org.jruby.RubyProc.call(RubyProc.java:289)
org.jruby.RubyProc.call(RubyProc.java:246)
org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:104)
java.lang.Thread.run(Thread.java:748)
[2018-04-06T12:54:48,052][DEBUG][logstash.agent] 2018-04-06 12:54:48 +0200: Listen loop error: #<IOError: closed stream>
[2018-04-06T12:54:48,052][DEBUG][logstash.agent] org/jruby/RubyIO.java:3405:in `select'
/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/puma-2.16.0-java/lib/puma/server.rb:322:in `handle_servers'
/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/puma-2.16.0-java/lib/puma/server.rb:296:in `block in run'
[2018-04-06T12:54:48,052][DEBUG][logstash.agent] 2018-04-06 12:54:48 +0200: Listen loop error: #<IOError: closed stream>
```

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [April 6, 2018, 6:50pm UTC](https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083/2 "2018-04-06T18:50:33Z")

</div>

Upon investigation this error raised by the `awesome_print` library points to a problem with the value in the `ENV['HOME']` environment variable. It is probably not set.

This will only occur if `ENV['HOME']` is not set AND the rubydebug codec is used. The awesome\_print library maintainers have fixed this in master but not released the fix yet. I have asked them to do this.

That said, even if it was fixed, you might still have problems with Logstash or some plugins as the [POSIX specification](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html) requires that it is set.

---

<div class="post-metadata">

**Author:** ![hzarrabi](https://avatars.discourse-cdn.com/v4/letter/h/f9ae1b/32.png) [@hzarrabi](https://discuss.elastic.co/u/hzarrabi)\
**Post date:** [April 8, 2018, 1:35pm UTC](https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083/3 "2018-04-08T13:35:01Z")

</div>

Hi,  
Thanks for replaying.  
Is there any temporary solution before fixing the bug?  
Where should I set this environment variable in my installation?  
Regards

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [April 9, 2018, 9:50pm UTC](https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083/4 "2018-04-09T21:50:39Z")

</div>

The temporary solution is to set `HOME` in the shell that runs Logstash.

Is it a service or a manual invocation?

---

<div class="post-metadata">

**Author:** ![hzarrabi](https://avatars.discourse-cdn.com/v4/letter/h/f9ae1b/32.png) [@hzarrabi](https://discuss.elastic.co/u/hzarrabi)\
**Post date:** [April 10, 2018, 10:52pm UTC](https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083/5 "2018-04-10T22:52:55Z")

</div>

Hi,

That is running as a service.

Could I hard code it some where ?

Regards

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 8, 2018, 10:52pm UTC](https://discuss.elastic.co/t/listen-loop-error-ioerror-closed-stream/127083/6 "2018-05-08T22:52:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
