Fix receiving partial message from nsq

This commit is contained in:
2021-02-01 02:38:19 +03:00
parent 3c0ec5574d
commit db988a0914

View File

@@ -44,10 +44,16 @@ final class NsqSocket
{ {
$buffer = $this->input; $buffer = $this->input;
$size = Bytes::BYTES_SIZE;
do {
$buffer->append( $buffer->append(
$this->socket->read(Bytes::BYTES_SIZE), $this->socket->read($size),
); );
$size -= $buffer->size();
} while ($buffer->size() < Bytes::BYTES_SIZE);
if ('' === $buffer->bytes()) { if ('' === $buffer->bytes()) {
throw new ConnectionFail('Probably connection closed.'); throw new ConnectionFail('Probably connection closed.');
} }