ruby kafka parse error - ruby

I am trying to parse a kafka topic using Ruby.
my code :
require 'kafka'
kafka = Kafka.new(seed_brokers: ["someserver"])
kafka.each_message(topic: "topicname") do |message|
puts message.offset, message.key, message.value
end
I am getting below error:
/Users/someuser/.rbenv/versions/2.4.2/lib/ruby/2.4.0/optparse.rb:1644:in `parse!': unknown keywords: seed_brokers, client_id (ArgumentError)
from /Users/someuser/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/kafka-0.0.2/lib/kafka.rb:66:in `parse'
from /Users/someuser/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/kafka-0.0.2/lib/kafka.rb:16:in `initialize'
from KafkaConnect.rb:4:in `new'
from KafkaConnect.rb:4:in `<main>'
Not sure what is the issue, I have checked the documentation and there seems to be no problem.
I have also checked using kafkacat and it is able to stream the data without no issues. challenge is with Ruby.

Related

YARD infinitely recurses on Ruby project

Ruby 3.0.0, YARD 0.9.28, Linux (Fedora 35).
Running yardoc on my project works through most of the tasks, but blows up with an apparent infinite recursion when it comes to the Serializing to doc/top-level-namespace.html. I had this problem earlier in development, but I have no idea what I did to make it go away — and now it's back.
It might have something to do with the convoluted interplay of include and extend uses; there are four modules in the project that get mixed into almost every source file in some combination or other. Regardless, this has me stumped, and I haven't found anything like it online.
Here's the tail-end of the processing (I had to pull it out of the Rake task and do it by hand because the Rake output didn't compress the repeating lines):
% bundle exec yardoc
:
:
[debug]: Parsing ["config/macros.yard", "lib/sptaf.rb", "lib/sptaf/classmethods.rb", "lib/sptaf/cli.rb", "lib/sptaf/container.rb", "lib/sptaf/debugging.rb", "lib/sptaf/exceptions.rb", "lib/sptaf/faction.rb", "lib/sptaf/feature.rb", "lib/sptaf/game.rb", "lib/sptaf/inventory.rb", "lib/sptaf/item.rb", "lib/sptaf/location.rb", "lib/sptaf/mixin/actor.rb", "lib/sptaf/mixin/container.rb", "lib/sptaf/mixin/location.rb", "lib/sptaf/mixin/thing.rb", "lib/sptaf/npc.rb", "lib/sptaf/player.rb", "lib/sptaf/version.rb"] with `ruby` parser
[debug]: Parsing config/macros.yard
[debug]: Parsing lib/sptaf.rb
[debug]: Parsing lib/sptaf/classmethods.rb
:
:
[debug]: Serializing to doc/top-level-namespace.html
bundler: failed to load command: yardoc (./vendor/bundle/ruby/3.0.0/bin/yardoc)
./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/proxy.rb:101:in `path': stack level too deep (SystemStackError)
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/proxy.rb:129:in `equal?'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:15:in `block in inheritance_tree'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `map'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `inheritance_tree'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/proxy.rb:180:in `method_missing'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:17:in `block in inheritance_tree'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `map'
from ./vendor/bundle/ruby/3.0.0/gems/yard-0.9.28/lib/yard/code_objects/module_object.rb:14:in `inheritance_tree'
... 10681 levels...
from /usr/share/gems/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
from /usr/share/gems/gems/bundler-2.2.33/libexec/bundle:37:in `<top (required)>'
from /home/coar/bin/bundle:23:in `load'
from /home/coar/bin/bundle:23:in `<main>'
Here is the .yardopts file it is using:
--charset="utf-8"
--verbose
--debug
--backtrace
--no-cache
--title="Text Adventure Framework (TAF) Gem"
--private
--embed-mixins
--markup-provider="rdiscount"
--markup="markdown"
config/macros.yard
lib/sptaf.rb
lib/sptaf/classmethods.rb
lib/sptaf/cli.rb
lib/sptaf/container.rb
lib/sptaf/debugging.rb
lib/sptaf/exceptions.rb
lib/sptaf/faction.rb
lib/sptaf/feature.rb
lib/sptaf/game.rb
lib/sptaf/inventory.rb
lib/sptaf/item.rb
lib/sptaf/location.rb
lib/sptaf/mixin/actor.rb
lib/sptaf/mixin/container.rb
lib/sptaf/mixin/location.rb
lib/sptaf/mixin/thing.rb
lib/sptaf/npc.rb
lib/sptaf/player.rb
lib/sptaf/version.rb
-
CHANGELOG.md
CODE_OF_CONDUCT.md
LICENCE.md
README.md
TODO.md
My apologies if the #documentation tag is inappropriate here; it says it's for questions about document generators, which seems to kinda fit.
As always, thanks for reading and particularly for any kind feedback!

connection closed by server error when getting accounts using coinbase-exchange websocket

I'm using the ruby coinbase-exchange gem, and I'm executing the code by copying and pasting it into irb.
This only happens when I'm running it as a websocket – when I just execute the code on its own, without the socket, it works fine.
When the following code executes,
accounts = Array.new(2, Array.new)
rest_api.accounts do |resp|
accounts = resp
end
this error is produced:
Coinbase::Exchange::APIError: GET https://api.exchange.coinbase.com/accounts?: connection closed by server
from /usr/local/lib/ruby/gems/2.3.0/gems/coinbase-exchange-0.1.2/lib/coinbase/exchange/adapters/em_http.rb:59:in `block in http_verb'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/em/deferrable.rb:158:in `set_deferred_status'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/em/deferrable.rb:198:in `fail'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/client.rb:123:in `on_error'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/client.rb:117:in `unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `block in unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `map'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:31:in `unbind'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:1481:in `event_callback'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:202:in `release_machine'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:202:in `ensure in run'
from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:205:in `run'
from (irb):79
from /usr/local/bin/irb:11:in `<main>'
What's the problem here? How do I get around it?

Watir webdriver not working as expected

I tried to execute a simple browser test
require 'rubygems'
require 'watir-webdriver'
b = Watir::Browser.new :firefox
b.goto 'http://www.google.com/'
The browser launched and closed immediately throwing the following error
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)
from c:/ruby22/lib/ruby/2.2.0/net/http/request.rb:14:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new_request_for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:57:in `request'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:88:in `request'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:123:in `create_session'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:87:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:55:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from test.rb:3:in `new'
from test.rb:3:in `<main>'
HTTP request path is empty means what? is the calling parameters changed in new versions of watir?
Anyone faced similar problem?
My System is Windows 7 64 bit, I am running behind a proxy, the browser already configured with a proxy
---EDIT---
I have introduced a trailing slash, but I am getting a new error now and also getting the previous error, every time I have to change the code and save it to get this error
c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from test.rb:8:in `new'
from test.rb:8:in `<main>'
---EDIT---
I have downloaded the geckodriver v0.10.0 from https://github.com/mozilla/geckodriver/releases and copy pasted the geckodriver.exe in to the firefox folder and also added the firefox folder to the PATH
I installed the selenium-webdriver beta version 3.0.0.beta2.1
But still I am getting the same error
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)
I have also tried installing the Firefox ESR version and added to PATH which is also not working
---EDIT---
I opened the file c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb
and introduced print statement as follows
print "\n"
print uri_or_path
if URI === uri_or_path then
print "\ncoming to if part\n"
#uri = uri_or_path.dup
host = #uri.hostname.dup
host << ":".freeze << #uri.port.to_s if #uri.port != #uri.default_port
#path = uri_or_path.request_uri
raise ArgumentError, "no HTTP request path given" unless #path
else
print "\ncoming to else part\n"
#uri = nil
host = nil
raise ArgumentError, "no HTTP request path given" unless uri_or_path
raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
#path = uri_or_path.dup
end
And I got the below output
/session
coming to else part
coming to else part
/shutdown
coming to else part
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:29:in `initialize': HTTP request path is empty (ArgumentError)
Try entering those commands in IRB, a line at a time. that will make it clearer where the failure is occuring
Your initial error indicated it was failing on line 3,which in your code above is where it tries to create a new instance of a browser object (which also launches firefox, and then tries to connect the browser object to the actual browser). If that's not working it's usually because you are not using a version of webdriver that supports your browser. Perhaps you have a brand new firefox, and need to update webdriver.
Sometimes there is a brief window after a new FF comes out (every 6 weeks) that introduced a breaking change, where we don't have an updated webdriver gem that supports that version.
Most likely you were seeing this due to a bug in Firefox 47.0. You need to update to Firefox 47.0.1 for it to work with Selenium 2.53.4.

dRuby server crashes when probed on the port its listening on

I have this test code:
require 'drb/drb'
DRb.start_service(nil, "hello")
puts DRb.uri
DRb.thread.join()
If I then probe the port it grabs using something like nmap, after a few probes, the app crashes.
Under JRuby 1.7, I get this stack:
Errno::ENOPROTOOPT: Protocol not available - Protocol not available
setsockopt at org/jruby/ext/socket/RubyBasicSocket.java:294
set_sockopt at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:1005
initialize at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:927
accept at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:991
main_loop at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:1615
run at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:1465
Under Ruby 1.9.3-392, the stack is this:
/Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:964:in `setsockopt': Invalid argument (Errno::EINVAL)
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:964:in `set_sockopt'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:886:in `initialize'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:950:in `new'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:950:in `accept'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:1574:in `main_loop'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:1424:in `block in run'
Is there a way to make dRuby more robust (for example an option or config setting somewhere) and not crash in these situations.
UPDATE
By putting the code in a loop like so, this seems to make it more resilient - but is that best way forward:
while true
begin
DRb.start_service("druby://localhost:12345", "hello")
puts DRb.uri
DRb.thread.join()
rescue Exception => e
puts e.message
end
end
TIA

Soap4r : the requested address is not valid in the its context

I was wondering if somebody has seen this error before?
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:675:in `initialize': The requested address is not valid in its context. - connect(2) (://:0) (Errno::EADDRNOTAVAIL)
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:675:in `new'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:675:in `create_socket'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:632:in `connect'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/timeout.rb:128:in `timeout'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:631:in `connect'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:522:in `query'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient/session.rb:147:in `query'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:953:in `do_get_block'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:765:in `do_request'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:848:in `protect_keep_alive_disconnected'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:764:in `do_request'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:666:in `request'
from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.1.5.2/lib/httpclient.rb:596:in `post'
from C:/Ruby/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/streamHandler.rb:238:in `send_post'
from C:/Ruby/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/streamHandler.rb:172:in `send'
from C:/Ruby/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/proxy.rb:179:in `route'
from C:/Ruby/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/proxy.rb:143:in `call'
from C:/Ruby/lib/ruby/gems/1.8/gems/soap4r-1.5.8/lib/soap/rpc/driver.rb:181:in `call'
from (eval):6:in `preRepairAuthorizationQA'
from C:/documents and settings/ngorbikoff/Desktop/GMW/WSDL/ProcessMessageClient.rb:21
I'm trying to connect to a service, I just generated this soap client from wsdl2ruby. Everything went fine. So I have no idea why this error is happening. This is a fresh install of ruby 1.8.7 on Windows, but I tested this on another Windows machine with Ruby 1.8.6 and on a Debian server with REE 1.8.7 - same error. My gut feeling is that it has to do with the httpclient lib - but I can't find anything on google - regarding this err, other than some references to Pythong and tcl - which seem to be unrelated. Also I'm trying to connect to wsdl service that is on httpS - but I didn't have this problem before and there were no changes on the server.
Does anyone have any insight?
OK nevermind people. For anyone else looking into this cryptic message if you are using wsdl2ruby - make sure that you define your endpoint_url in the WhateverServiceClient.rb file generated by the wsdl3ruby.

Resources