cppkafka icon indicating copy to clipboard operation
cppkafka copied to clipboard

cppkafka::HandleException' what(): Local: Timed out Aborted (core dumped)

Open marcoippolito opened this issue 7 years ago • 7 comments

Hi, after starting Kafka server, I compiled in my Ubuntu 18.04.01 Server Edition, the following small example found in cppakafka main page:

`#include <cppkafka/cppkafka.h>

using namespace std;
using namespace cppkafka;

int main() {
  // Create the config
  Configuration config = {
    { "metadata.broker.list", "127.0.0.1:9092" }
  };

  // Create the producer
  Producer producer(config);

  // Produce a message!
  string message = "hey there!";
  producer.produce(MessageBuilder("my_topic").partition(0).payload(message));
  producer.flush();

  return 0;
}
`

g++ -std=c++17 -lrdkafka -lpthread -lz -lstdc++ plain.cpp -lboost_program_options -lcppkafka -oplain ./plain terminate called after throwing an instance of 'cppkafka::HandleException' what(): Local: Timed out Aborted (core dumped)

What might be the cause? Looking forward to your kind help. Marco

marcoippolito avatar Nov 02 '18 19:11 marcoippolito

I mentioned something about that in this other ticket. Unfortunately this is rdkafka's fault, as what cppkafka is doing there is just calling rdkafka's functions. It looks like rdkafka isn't connected somehow.

I haven't created a ticket on the rdkafka repo yet for this issue, nor do I know if there's already one. If you do create it, please link it here.

mfontanini avatar Nov 02 '18 21:11 mfontanini

I created a ticket here: https://github.com/edenhill/librdkafka/issues/2087 Please coordinate with Magnus in order to solve this problem, and may be, to set a a schedule for the advancement of both your important libraries

marcoippolito avatar Nov 03 '18 07:11 marcoippolito

Where to set the configuration for the debugging? I tried few "options", but didn't find the proper syntax / way:

#include <cppkafka/cppkafka.h>

using namespace std;
using namespace cppkafka;

int main() {
  // Create the config
  //Configuration config = {
    //{ "metadata.broker.list", "127.0.0.1:9092"},
    //{ "msg", "broker", "topic"}
  //};

  //DebugConfiguration debug_configuration = {
    //{"msg","broker","topic"}
  //};
  //Configuration config = {
    //{ "metadata.broker.list", "127.0.0.1:9092", "msg", "broker", "topic"}
  //};
  //Configuratioon config = {
    //{ "metadata.broker.list", "127.0.0.1:9092", "debug"}
  //};

  Configuration config = {
    { "metadata.broker.list", "127.0.0.1:9092"}
  };

  // Create the producer
  Producer producer(config);
  // Produce a message!
  string message = "hey there!";
  producer.produce(MessageBuilder("my_topic").partition(0).payload(message));
  producer.flush();
  return 0;
}

marcoippolito avatar Nov 03 '18 09:11 marcoippolito

Append add another option to the config with key "debug" and some valid debug value (e.g. "all").

mfontanini avatar Nov 03 '18 14:11 mfontanini

Adding these lines:

`  Configuration debug = {
    { "all"}
  };
`

`g++ -std=c++17 -lrdkafka -lpthread -lz -lstdc++ plain.cpp -lboost_program_options -lcppkafka 
-oplain
plain.cpp: In function ‘int main()’:
plain.cpp:14:3: error: could not convert ‘{{"all"}}’ from ‘<brace-enclosed initializer list>’ to    
‘cppkafka::Configuration’
   };
`

While adding these lines:

`  Configuration debug = {
    "all"
  };

`g++ -std=c++17 -lrdkafka -lpthread -lz -lstdc++ plain.cpp -lboost_program_options -lcppkafka 
-oplain
plain.cpp: In function ‘int main()’:
plain.cpp:14:3: error: could not convert ‘{"all"}’ from ‘<brace-enclosed initializer list>’ to 
‘cppkafka::Configuration’
   };
   ^

marcoippolito avatar Nov 04 '18 16:11 marcoippolito

The ConfugurationOption constructor takes a string and a value (string, bool, int) hence something like:

Configuration c = {{"option1","value"}, {"option2",true},{"option3",3}}

accelerated avatar Nov 04 '18 16:11 accelerated

With this code:

`#include <cppkafka/cppkafka.h>

using namespace std;
using namespace cppkafka;
int main() {
  // Create the config
  Configuration config = {{ "metadata.broker.list", "127.0.0.1:9092"} , {"debug","all"}};
  // Create the producer
  Producer producer(config);
  // Produce a message!
  string message = "hey there!";
  producer.produce(MessageBuilder("my_topic").partition(0).payload(message));
  producer.flush();
  return 0;
}
`

After starting kafka server and two new nodes http://kafka.apache.org/quickstart , I compiled and then executed the above file:

g++ -std=c++17 -lrdkafka -lpthread -lz -lstdc++ plain.cpp -lboost_program_options -lcppkafka 
-oplain

Please find attached the output: plainOutput.txt

marcoippolito avatar Nov 06 '18 16:11 marcoippolito