KafkaEx help - not able to get hello world going

I’m not able to get KafkaEx working. I’ve added the dependencies and use all the default configs, and I get the following when I run %> iex -S mix

[info] Application kafka_ex exited: KafkaEx.start(:normal, []) returned an error: an exception was raised:
    ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.Stream, DBConnection.PrepareStream, KafkaEx.Stream, HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream
        (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
        (elixir) lib/enum.ex:141: Enumerable.reduce/3
        (elixir) lib/enum.ex:3023: Enum.map/2
        (kafka_ex) lib/kafka_ex/server_0_p_10_and_later.ex:87: KafkaEx.Server0P10AndLater.kafka_server_init/1
        (stdlib) gen_server.erl:374: :gen_server.init_it/2
        (stdlib) gen_server.erl:342: :gen_server.init_it/6
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application kafka_ex: KafkaEx.start(:normal, []) returned an error: an exception was raised:
    ** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom. This protocol is implemented for the following type(s): Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.Stream, DBConnection.PrepareStream, KafkaEx.Stream, HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream
        (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
        (elixir) lib/enum.ex:141: Enumerable.reduce/3
        (elixir) lib/enum.ex:3023: Enum.map/2
        (kafka_ex) lib/kafka_ex/server_0_p_10_and_later.ex:87: KafkaEx.Server0P10AndLater.kafka_server_init/1
        (stdlib) gen_server.erl:374: :gen_server.init_it/2
        (stdlib) gen_server.erl:342: :gen_server.init_it/6
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Could you please show us the kafka_ex related code?

I’m not using kafka_ex but skimmed code around the line mentioned in the stack trace, also I did a brief read of parts of the documentation, and it seems as if for some reason your client is created with uris: nil, rather than a list of tuples.

Thanks for replying!

I don’t have any kafka_ex code, just the default install and config. https://github.com/kafkaex/kafka_ex . That’s the vexing part, that I just added the dependency and tried to startup iex, and I am getting this error.

Config is code in elixir.

Also I can’t find “default” config, but only “example” config.

Additionally, it might be nice to know your version of elixir, OTP, and kafka_ex (according to mix.lock).

Thanks again…here’s the info…

elixir 1.9.4 (compiled with Erlang/OTP 22)
kafka_ex “0.10.0” (mix.lock)

and the config is in deps/kafka_ex/config/confix.exs …or is that just an example, and the config should be placed somewhere else?

Configuration of dependencies is not read. It might clash with configuration you want to put on your own. Therefore you need to create a config/config.exs with the configuration you want in your applications root.

3 Likes

Thank you, NobbZ!