# Logstash websocket input plugin throwing NoMethodError exception

**URL:** <https://discuss.elastic.co/t/logstash-websocket-input-plugin-throwing-nomethoderror-exception/237081>\
**Category:** Logstash\
**Created:** [June 15, 2020, 7:32am UTC](https://discuss.elastic.co/t/logstash-websocket-input-plugin-throwing-nomethoderror-exception/237081 "2020-06-15T07:32:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlessandroKP](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alessandrokp/32/45312_2.png) [@AlessandroKP](https://discuss.elastic.co/u/AlessandroKP)\
**Post date:** [June 15, 2020, 7:32am UTC](https://discuss.elastic.co/t/logstash-websocket-input-plugin-throwing-nomethoderror-exception/237081/1 "2020-06-15T07:32:26Z")

</div>

Hi all,

I am having some troubles using the Logstash websocket input plugin.

I need Logstash to read a stream of events from a websocket endpoint and thus I am trying the following pipeline configuration

```auto
input {
	websocket {
		url => "wss://my/url?key=mykey"
		mode => "client"
	}
}

filter {
}

output {
	stdout {
		codec => "rubydebug"
	}
}

```

The pipeline is starting without any error, however I am not getting any output on console. Instead I get the following log message

> [WARN][logstash.inputs.websocket][test-websocket] websocket input client threw exception, restarting {: **exception=\>#\<NoMethodError: undefined method `redirect?' for nil:NilClass\>** }

repeated every few seconds.

I am currently using **Logstash 7.7.0**.

What could be the cause of this exception?

I am sure that the websocket is streaming data because I can connect to it with a command-line client and I can receive the events through it, but it looks like Logstash has a problem connecting to the endpoint or it is not able to process the events.

Anyone had the same problem?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 15, 2020, 12:40pm UTC](https://discuss.elastic.co/t/logstash-websocket-input-plugin-throwing-nomethoderror-exception/237081/2 "2020-06-15T12:40:42Z")

</div>

Possibly [this](https://github.com/logstash-plugins/logstash-input-websocket/issues/3) issue?

---

<div class="post-metadata">

**Author:** ![AlessandroKP](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alessandrokp/32/45312_2.png) [@AlessandroKP](https://discuss.elastic.co/u/AlessandroKP)\
**Post date:** [June 16, 2020, 7:52am UTC](https://discuss.elastic.co/t/logstash-websocket-input-plugin-throwing-nomethoderror-exception/237081/3 "2020-06-16T07:52:12Z")

</div>

Hi @Badger,

thanks for the reply.

I followed the suggestion contained in this [**issue**](https://github.com/logstash-plugins/logstash-input-websocket/issues/3), by putting a trailing slash to the URL in the websocket input parameter **url** , i.e.

```auto
input {
	websocket {
		url => "wss://<URL>?key=<KEY>/"
		mode => "client"
	}
}

filter {
}

output {
	stdout {
		codec => "rubydebug"
	}
}

```

but now I get the following error:

```
warning: thread "Api Webserver" terminated with exception (report_on_exception is true):
Errno::EADDRNOTAVAIL: Cannot assign requested address - bind - Cannot assign requested address
        initialize at org/jruby/ext/socket/RubyTCPServer.java:127
               new at org/jruby/RubyIO.java:876
  add_tcp_listener at /app/logstash-7.7.1/vendor/bundle/jruby/2.5.0/gems/puma-4.3.5-java/lib/puma/binder.rb:229
  add_tcp_listener at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/forwardable.rb:229
   start_webserver at /app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:104
               run at /app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:60
              each at org/jruby/RubyRange.java:526
   each_with_index at org/jruby/RubyEnumerable.java:1258
               run at /app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:55
   start_webserver at /app/logstash-7.7.1/logstash-core/lib/logstash/agent.rb:393
[2020-06-16T09:45:30,979][FATAL][logstash.runner] An unexpected error occurred! {:error=>#<Errno::EADDRNOTAVAIL: Cannot assign requested address - bind - Cannot assign requested address>, :backtrace=>["org/jruby/ext/socket/RubyTCPServer.java:127:in `initialize'", "org/jruby/RubyIO.java:876:in `new'", "/app/logstash-7.7.1/vendor/bundle/jruby/2.5.0/gems/puma-4.3.5-java/lib/puma/binder.rb:229:in `add_tcp_listener'", "/app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:104:in `start_webserver'", "/app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:60:in `block in run'", "org/jruby/RubyRange.java:526:in `each'", "org/jruby/RubyEnumerable.java:1258:in `each_with_index'", "/app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:55:in `run'", "/app/logstash-7.7.1/logstash-core/lib/logstash/agent.rb:393:in `block in start_webserver'"]}
[...][ERROR][org.logstash.Logstash] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

```

and Logstash just stops.

---

<div class="post-metadata">

**Author:** ![AlessandroKP](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alessandrokp/32/45312_2.png) [@AlessandroKP](https://discuss.elastic.co/u/AlessandroKP)\
**Post date:** [June 29, 2020, 10:02am UTC](https://discuss.elastic.co/t/logstash-websocket-input-plugin-throwing-nomethoderror-exception/237081/4 "2020-06-29T10:02:48Z")

</div>

Hi all,

I got some updates on the issue.

By looking on the Internet, it seems that the problem might be caused by **some other client listening on the default port for WSS connection** ,  
hence the error message "Errno::EADDRNOTAVAIL: Cannot assign requested address".

By checking with netstat it looks like there are no connections on ports 80 and 443.

So, I tried the following things:

- start logstash with root privileges
- replace **wss** protocol with **ws** in the URL of the websocket endpoint:

```auto
input {
	websocket {
		url => "ws://<URL>?key=<KEY>/"
		mode => "client"
	}
}

filter {
}

output {
	stdout {
		codec => "rubydebug"
	}
} 

```

In both cases, I get the same error message as in my last post:

```
warning: thread "Api Webserver" terminated with exception (report_on_exception is true):
Errno::EADDRNOTAVAIL: Cannot assign requested address - bind - Cannot assign requested address
        initialize at org/jruby/ext/socket/RubyTCPServer.java:127
               new at org/jruby/RubyIO.java:876
  add_tcp_listener at /app/logstash-7.7.1/vendor/bundle/jruby/2.5.0/gems/puma-4.3.5-java/lib/puma/binder.rb:229
  add_tcp_listener at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/forwardable.rb:229
   start_webserver at /app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:104
               run at /app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:60
              each at org/jruby/RubyRange.java:526
   each_with_index at org/jruby/RubyEnumerable.java:1258
               run at /app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:55
   start_webserver at /app/logstash-7.7.1/logstash-core/lib/logstash/agent.rb:393
[...][FATAL][logstash.runner] An unexpected error occurred! {:error=>#<Errno::EADDRNOTAVAIL: Cannot assign requested address - bind - Cannot assign requested address>, :backtrace=>["org/jruby/ext/socket/RubyTCPServer.java:127:in `initialize'", "org/jruby/RubyIO.java:876:in `new'", "/app/logstash-7.7.1/vendor/bundle/jruby/2.5.0/gems/puma-4.3.5-java/lib/puma/binder.rb:229:in `add_tcp_listener'", "/app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:104:in `start_webserver'", "/app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:60:in `block in run'", "org/jruby/RubyRange.java:526:in `each'", "org/jruby/RubyEnumerable.java:1258:in `each_with_index'", "/app/logstash-7.7.1/logstash-core/lib/logstash/webserver.rb:55:in `run'", "/app/logstash-7.7.1/logstash-core/lib/logstash/agent.rb:393:in `block in start_webserver'"]}
[...][ERROR][org.logstash.Logstash] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

```

I also tried starting Logstash with simple stdin input configuration to see if the problem is related to some general setting:

`bin/logstash -e "input{stdin{}} output{stdout{codec=>rubydebug}}"`

and Logstash is starting without any problems.

Maybe the logstash settings file **logstash.yml** could be helpful information. Here it is:

```
node.name: logstash-${HOSTNAME}
log.level: info
http.host: "${HOSTNAME}"
http.port: 9600
config.reload.automatic: true
config.reload.interval: 3s

```

Any idea on what could be the cause of the error?

---

<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:** [July 27, 2020, 10:13am UTC](https://discuss.elastic.co/t/logstash-websocket-input-plugin-throwing-nomethoderror-exception/237081/5 "2020-07-27T10:13:22Z")

</div>

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