unexpected eof php,php - Unexpected EOF while reading from stream KAFKA CONSUME读取消息出错

请教各位大神,php kafka consume端如何取消息。

读取方法:

$readable = @stream_select($read, $null, $null, $this->recvTimeoutSec, $this->recvTimeoutUsec);

if ($readable > 0) {

$remainingBytes = $len;

$data = $chunk = '';

while ($remainingBytes > 0) {

$chunk = fread($this->stream, $remainingBytes);

if ($chunk === false) {

$this->close();

throw new Kafka_Exception_Socket_EOF('Could not read '.$len.' bytes from stream (no data)');

}

if (strlen($chunk) === 0) {

// Zero bytes because of EOF?

if (feof($this->stream)) {

$this->close();

throw new Kafka_Exception_Socket_EOF('Unexpected EOF while reading '.$len.' bytes from stream (no data)');

}

// Otherwise wait for bytes

$readable = @stream_select($read, $null, $null, $this->recvTimeoutSec, $this->recvTimeoutUsec);

if ($readable !== 1) {

throw new Kafka_Exception_Socket_Timeout('Timed out reading socket while reading ' . $len . ' bytes with ' . $remainingBytes . ' bytes to go');

}

continue; // attempt another read

}

$data .= $chunk;

$remainingBytes -= strlen($chunk);

}

if ($len === $remainingBytes || ($verifyExactLength && $len !== strlen($data))) {

// couldn't read anything at all OR reached EOF sooner than expected

$this->close();

throw new Kafka_Exception_Socket_EOF('Read ' . strlen($data) . ' bytes instead of the requested ' . $len . ' bytes');

}

抛出异常:Kafka_Exception_Socket_EOF: Unexpected EOF while reading 4 bytes from stream (no data) #0

请教各位大神,如何解决。不胜感激。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值