Fix receiving partial message from nsq
This commit is contained in:
@@ -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.');
|
||||||
|
Reference in New Issue
Block a user