• mqtt发布时报错问题之一处理


    今天遇到一个很奇怪的问题,我在发布小字节的时候发布代码是正常的,一但长度过长就会直接报错报错代码行:

    protected function _fwrite($buffer)
    {

    $buffer_length = strlen($buffer);
    for ($written = 0; $written < $buffer_length; $written+=$fwrite) {
    $fwrite = fwrite($this->socket,substr($buffer, $written));
    if ($fwrite === false) {
    return false;
    }
    }
    return $buffer_length;
    }

     phpMQTT 类文件里面开始修改:

    protected function _fwrite($buffer)
    {

    $buffer_length = strlen($buffer);
    for ($written = 0; $written < $buffer_length; $written+=$fwrite) {
    $fwrite = fwrite($this->socket,substr($buffer, $written),1);
    if ($fwrite === false) {
    return false;
    }
    }
    return $buffer_length;
    }

    在后面加一个$fwrite()函数后面加一个1就行了,

    希望能对大家有帮助

  • 相关阅读:
    网络资源(4)
    网络资源(3)
    网络资源(2)
    网络资源(1)
    OCP读书笔记(27)
    OCP读书笔记(26)
    OCP读书笔记(25)
    OCP读书笔记(24)
    OCP读书笔记(23)
    OCP读书笔记(22)
  • 原文地址:https://www.cnblogs.com/leiqi/p/13223080.html
Copyright © 2020-2023  润新知