php-react-memcached icon indicating copy to clipboard operation
php-react-memcached copied to clipboard

Incorrect handle big message

Open Logioniz opened this issue 6 years ago • 0 comments

When message is big then you should collect whole message via chunk of data.

In Client.php you have this code:

    protected function setConnectionHandlers(): void
    {
        $this->connection->on('data', function ($chunk) {
            $parsed = $this->parser->parseRawResponse($chunk);
            $this->resolveRequests($parsed);
        });
        ...
   }

It looks like you are not collecting the complete message through pieces of data, i.e. you think you have a full response from the server.

Test to check problem:

<?php

$loader = require __DIR__ . '/vendor/autoload.php';

$loop = React\EventLoop\Factory::create();

use \seregazhuk\React\Memcached\Factory;

$memcached = Factory::createClient($loop, '127.0.0.1:9003');

$memcached->set('a', str_repeat('a', 1000000))
        ->then(function () use ($memcached) {
            return $memcached->get('a');
        })
        ->then(function ($data) use ($loop) {
            // var_dump($data);
            var_dump(1111);
            $loop->stop();
        });

$loop->run();

Logioniz avatar Mar 27 '19 15:03 Logioniz