Logstash websocket input plugin throwing NoMethodError exception

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

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?

1 Like

Possibly this issue?

Hi @Badger,

thanks for the reply.

I followed the suggestion contained in this issue, by putting a trailing slash to the URL in the websocket input parameter url, i.e.

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.

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:
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?

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