Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marcoippolito opened this issue Nov 2, 2018 · 7 comments

Comments

@marcoippolito
Copy link

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

@mfontanini
Copy link
Owner

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.

@marcoippolito
Copy link
Author

I created a ticket here: confluentinc/librdkafka#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
Copy link
Author

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;
}

@mfontanini
Copy link
Owner

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

@marcoippolito
Copy link
Author

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’
   };
   ^

@accelerated
Copy link
Contributor

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

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

@marcoippolito
Copy link
Author

marcoippolito commented Nov 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants