confluentinc / librdkafka

The Apache Kafka C/C++ library
Other
175 stars 3.14k forks source link

kafka broker down or network disconnection,program will throw exception and stop #401

Closed MayBing closed 8 years ago

MayBing commented 8 years ago

How can I catch the exception and Make the program continues to run and try reconnect in seconds. Thank you very much!

edenhill commented 8 years ago

librdkafka does not throw any exceptions, and it will automatically reconnect whenever a broker connection is disconnected.

MayBing commented 8 years ago

oh,sorry!,I kill kakfa server then I test my program,no cores,no exceptions. I beg you and ask a question. when I start kafka produce,show some logs. "RDKAFKA-3-FAIL: rdkafka#producer-0:10.2.28.60:9092/bootstrap:Failed to connect to broker at ...1/1 brokers are down"

if log like this,kafka produce will reconnect with rd_kafka_thread_main function or program is down? Can you tell us your powerfull librdkafka implementation ideas?

edenhill commented 8 years ago

That means it can't connect to your broker. Did you give it the right address and port? Check connectivity with the broker, e.g.: "telnet " should give you a connection.

MayBing commented 8 years ago

Kafka produce server has dual ethernet(Internal network and external network),Kafka produce data and poll data to Internal network through haproxy server to external network. When haproxy is down,log will show.How can I deal with this situation.

edenhill commented 8 years ago

librdkafka needs to be able to connect with TCP to the brokers and it usually will not work with a proxy inbetween.

MayBing commented 8 years ago

Oh,thank you very much