Closed transistive closed 2 years ago
If you have problem with receiving data from server. Can it happen you will get only a part of chunk? what about something like this?
$msg = '';
while (true) {
$header = $this->connection->read(2);
$length = unpack('n', $header)[1] ?? 0; //because 0x00 0x00 end mark is chunk of size 0
if ($length > 0) {
$chunk = '';
$size = mb_strlen($chunk, '8bit');
while ($size < $length) {
$chunk .= $this->connection->read($length - $size);
}
$msg .= $chunk;
} else {
break;
}
}
not tested.. written in this comment.
It looks a bit better, but I will have to test it. I am currently working on something else, but will circle back to it later today or tomorrow.
@transistive I can try to update it but I will have time next week. Also I'm thinking about checking if reading header has returned length 2. Right now if it works for you ok, I'll make issue and check it next week.
Sounds like a great plan. Are you willing to release it in a minor version in the meantime or shall we wait?
if you need it we can make release
It would be nice to have so I can include it the release of the client which I have planned for the weekend
When running queries over 120 seconds, the sockets will read an empty string, leading to cryptic errors: https://github.com/neo4j-php/neo4j-php-client/issues/102
To solve this, I had to remove the assumption that empty strings result in a read error, and continue reading if a chunking symbol
0x00 0x00
appeared when no message has been read yet.According to the tests, everything still works