php-zookeeper icon indicating copy to clipboard operation
php-zookeeper copied to clipboard

Zookeeper::exists(): error: invalid zhandle state

Open airanvinay opened this issue 8 years ago • 5 comments

Getting Exception "Zookeeper::exists(): error: invalid zhandle state", I am using Zookeeper for Kafka. Need help to find out where i am wrong.

airanvinay avatar Mar 22 '17 07:03 airanvinay

Would you please paste your code?

Timandes avatar Apr 24 '17 06:04 Timandes

I got same error, too.

PHP Warning: array_merge(): Argument #1 is not an array in /app/test_kafka/mq/vendor/nmred/kafka-php/src/Kafka/Produce.php on line 136 PHP Warning: Zookeeper::exists(): error: invalid zhandle state in /app/test_kafka/mq/vendor/nmred/kafka-php/src/Kafka/ZooKeeper.php on line 208

my code:

$queue = msg_get_queue( $queue_id );
   
$msg_type = NULL;
$msg = NULL;
$max_msg_size = 16384;

$kafka = \Kafka\Produce::getInstance(KAFKA_SERVER, KAFKA_TIMEOUT);
$kafka->setRequireAck(-1);

while( msg_receive($queue, 1, $msg_type, $max_msg_size, $msg) )
{
   $msg->mq_data[ 'ymd' ] = date( 'Ymd' );
   $json_data = json_encode( $msg->mq_data );

   try {
       $kafka->setMessages(TEST_KAFKA_TOPIC_PREFIX.date('Ymd'), rand(0,99), $json_data);
       $kafka->send();
       $kafka->setMessages(TEST_KAFKA_TOPIC_CURRENT, rand(0,99), $json_data);
       $kafka->send();
   } catch( \Exception $e ) {
       echo "...failed, passed.\n";
   }

   $msg_type = NULL;
   $msg = NULL;
}

dsewnr avatar May 10 '17 03:05 dsewnr

If you use latest version of pecl/zookeeper, you will get an exception when ' invalid zhandle state' occurs.

You can contact the author of nmred/kafka-php to catch this exception.

Timandes avatar May 10 '17 07:05 Timandes

Can we close this issue now? : )

Timandes avatar Jan 01 '18 12:01 Timandes

Sure. ;p

dsewnr avatar Jan 01 '18 12:01 dsewnr