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,9 +44,15 @@ final class NsqSocket
{ {
$buffer = $this->input; $buffer = $this->input;
$buffer->append( $size = Bytes::BYTES_SIZE;
$this->socket->read(Bytes::BYTES_SIZE),
); do {
$buffer->append(
$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.');