bpot/poseidon

Exception in ensure_connected is unhelpful

Closed this issue · 1 comments

If someone specifies host.name=localhost in kafka server.properties or omits this config, the exception encountered when using poseidon to connect from another host is not helpful.

A common case would be to use vagrant and specify its ip address (as kafka_host).

producer = Poseidon::Producer.new(["#{kafka_host}:#{port}"], "sfx_producer")

poseidon reassigns @host (from kafka_host) to a value returned by kafka.

The subsequent exception is confusing, considering the ip address is valid. poseidon will obtain a valid socket, then fail when attempting to obtain another with the hostname provided by kafka.

If this hostname were identified via the exception (or the issue otherwise anticipated), users would be able to fix their hosts file or the kafka configuration -- without needing to obtain this information via debugging connection.rb.

host, port==>
192.168.111.88
9092
<==host,port

host, port==>
kafka.beatport.com
9092
<==host,port

/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/connection.rb:101:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/connection.rb:101:in `new'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/connection.rb:101:in `ensure_connected'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/connection.rb:39:in `produce'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/broker_pool.rb:42:in `execute_api_call'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/sync_producer.rb:112:in `send_to_broker'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/sync_producer.rb:53:in `block (2 levels) in send_messages'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/sync_producer.rb:52:in `each'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/sync_producer.rb:52:in `block in send_messages'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/sync_producer.rb:43:in `times'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/sync_producer.rb:43:in `send_messages'
    from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/poseidon-0.0.4/lib/poseidon/producer.rb:159:in `send_messages'
    from /Users/direwolf/Desktop/producer_test.rb:31:in `<main>'
bpot commented

Thanks for the detailed report! Fixed in #42.