php-rdkafka: connection down brokers. t try catch connection fail message. but can`t work

PHP version: 7.1.9 librdkafka version: 0.9.1 php-rdkafka version: 3.1.2 kafka version: 2.5.0 my php code

$kafkaBrokers = 'debian-server:9092';
$kafkaTopic = 'test';

$producer = new \RdKafka\Producer();
$producer->addBrokers($kafkaBrokers);
        
$topicConfig = new \RdKafka\TopicConf();
$topic = $producer->newTopic($kafkaTopic, $topicConfig);

// here block my web api, 
// i try catch exception, but can`t work
$topic->produce(RD_KAFKA_PARTITION_UA, 0, 'i am message');

i get error message

%3|1596426822.744|FAIL|rdkafka#producer-1| debian-server:9092/bootstrap: Failed to resolve 'debian-server:9092': %3|1596426822.
756|ERROR|rdkafka#producer-1| debian-server:9092/bootstrap: Failed to resolve 'debian-server:9092': %3|1596426822.767|ERROR|rdk
afka#producer-1| 1/1 brokers are down

I want to be able to return a response to the API after the connection fails

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Also, I’d highly suggest upgrading your librdkafka dependency. 0.9 as far as I know is no longer supported by phprdkafka and versions before 0.11.6 are known to have issues.