今天遇到一个很奇怪的问题,我在发布小字节的时候发布代码是正常的,一但长度过长就会直接报错报错代码行:
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就行了,
希望能对大家有帮助