cppkafka::HandleException' what(): Local: Timed out Aborted (core dumped)
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
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.
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
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;
}
Append add another option to the config with key "debug" and some valid debug value (e.g. "all").
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’
};
^
The ConfugurationOption constructor takes a string and a value (string, bool, int) hence something like:
Configuration c = {{"option1","value"}, {"option2",true},{"option3",3}}
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