Coder Social home page Coder Social logo

beansclient's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beansclient's Issues

Issues with large payload reserves

When I ->reserve(), I expect to get the next job; however, when my payloads get large (~16300 characters), the reservation just hangs and nothing happens. If I kill the script, and restart it, the same thing happens.

  • OS: Ubuntu 16.04.6 LTS
  • PHP: PHP 7.1.27-1+ubuntu16.04.1+deb.sury.org+1
  • BeansClient: Latest xoboty/beansclient

I'm running beanstalkd via a docker container:
schickling/beanstalkd

I've downloaded and installed the related beanstalkd-console docker, and it seems to pull the payload OK, and if I use the command line tools (beanstalk-cli) then it also can pull the payload.

Here is a script I use to replicate

<?php
if (PHP_SAPI !== 'cli') die('NO');
require __DIR__ . '/vendor/autoload.php';
use xobotyi\beansclient\BeansClient;
use xobotyi\beansclient\Connection;

$str = "a";
for ($i=0;$i<15280;$i++) {
    $str.='a'; //lets build a really long string
}

$connection = new Connection('10.15.21.49', '11300', 2, false);
$beansClient = new BeansClient($connection);

$loop = 0;
$s = $beansClient->stats();

print_r($s);

while ($loop < 1500 ) {
    $loop++;
    $str .= 'a'; //slowly increase the size of the string
    echo strlen($str);
    echo "\n";
    echo "Putting job\n";
    $beansClient->useTube('default')->put($str);
    echo "Getting job\n";
    $job = $beansClient->watchTube('default')->reserve();
    $id = $job->id;
    if (empty($id)) echo "No jobs...and timedout\n";
    else echo "Job is is " . $id . "\n";
    if ($id) {
        echo "\n";
        $len = strlen($job->payload);
        echo "\n";
        echo $len;
        echo "\n";
        $beansClient->delete($id);
    } else {
        die('ooops');
    }
}

I've checked

  • There is no similar issue from other users
  • Issue isn't fixed in dev branch

Serializer example is wrong, it should be new JsonSerializer()

Examples of beansclient\Serializer has the below reference:

use xobotyi\beansclient\Serializer\Json;
$client = new BeansClient(new Connection(), new Json());

which is wrong since the class name is JsonSerializer, the correct one should be.

use xobotyi\beansclient\Serializer\JsonSerializer;
$client = new BeansClient(new Connection(), new JsonSerializer());

Multiprocess consumption exception. What is the cause?

PHP Fatal error:  Uncaught xobotyi\beansclient\Exception\Command: Got unexpected status code [DEADLINE_SOON] in /home/Serve/Resque/vendor/xobotyi/beansclient/src/Command/Reserve.php:65
Stack trace:
#0 /home/Serve/Resque/vendor/xobotyi/beansclient/src/BeansClient.php(122): xobotyi\beansclient\Command\Reserve->parseResponse(Array, NULL)
#1 /home/Serve/Resque/vendor/xobotyi/beansclient/src/BeansClient.php(304): xobotyi\beansclient\BeansClient->dispatchCommand(Object(xobotyi\beansclient\Command\Reserve))
#2 /home/Serve/Resque/lib/src/Resque/Serve.php(46): xobotyi\beansclient\BeansClient->reserve()
#3 {main}
  thrown in /home/Serve/Resque/vendor/xobotyi/beansclient/src/Command/Reserve.php on line 65

Got unexpected status code [DEADLINE_SOON]

Bug causing a fatal error

PHP Fatal error: Uncaught xobotyi\beansclient\Exception\Command: Got unexpected status code [DEADLINE_SOON] in /data/beta/websocket/vendor/xobotyi/beansclient/src/Command/Reserve.php:65
Stack trace:
#0 /data/beta/websocket/vendor/xobotyi/beansclient/src/BeansClient.php(122): xobotyi\beansclient\Command\Reserve->parseResponse(Array, NULL)
#1 /data/beta/websocket/vendor/xobotyi/beansclient/src/BeansClient.php(304): xobotyi\beansclient\BeansClient->dispatchCommand(Object(xobotyi\beansclient\Command\Reserve))
#2 /data/beta/websocket/bin/wsbs-worker.php(30): xobotyi\beansclient\BeansClient->reserve(30)
#3 /data/beta/websocket/bin/wsbs-worker.php(261): BeanstalkdWorker->run()
#4 {main

It should understand "[DEADLINE_SOON]" which is in beanstalkd 1.10

  • Issue isn't fixed in dev branch

Single process consumption exception, what is the cause?

while (true) {
    try {
        $job = $beansClient->watchTube('Order')
            ->reserve();
        $payload = $job->payload;
        if (!empty($payload))
        {
            var_dump($job->payload);
        }
    } catch (\Exception $ex) {
        var_dump($ex->getTraceAsString());
        var_dump($beansClient->getConnection()->isActive());
        exit;
    }
}

Backtrace:

string(406) "#0 /home/Serve/Resque/vendor/xobotyi/beansclient/src/BeansClient.php(122): xobotyi\beansclient\Command\Reserve->parseResponse(Array, NULL)
#1 /home/Serve/Resque/vendor/xobotyi/beansclient/src/BeansClient.php(304): xobotyi\beansclient\BeansClient->dispatchCommand(Object(xobotyi\beansclient\Command\Reserve))
#2 /home/Serve/Resque/app/test/stalk.php(24): xobotyi\beansclient\BeansClient->reserve()
#3 {main}"
bool(true)

Задание MAX_PAYLOAD_SIZE вручную

Добрый день. Сделайте задание этого параметра самостоятельно. Так как сервер позволяет изменить максимальный размер тела сообщения. У меня например все данные не влазят, поэтому скрипт выкидывает исключение постоянно. Измените это с константы на статическую переменную. Спасибо!

public const MAX_PAYLOAD_SIZE = 65536;

unix sockets can not find/recognize socket file

Sample code snippet does not work and throws exception;

PHP Fatal error:  Uncaught xobotyi\beansclient\Exception\SocketException: Host `/tmp/beanstalkd.sock` not exists or unreachable in /beans/vendor/xobotyi/beansclient/src/Socket/SocketSocket.php:32
Stack trace:
#0 /beans/vendor/xobotyi/beansclient/src/Socket/SocketFactory.php(120): xobotyi\beansclient\Socket\SocketSocket->__construct('/tmp/beanstalkd...', -1, 2)
#1 /beans/vendor/xobotyi/beansclient/src/Connection.php(34): xobotyi\beansclient\Socket\SocketFactory->createSocket()
#2 /beans/writer.php(9): xobotyi\beansclient\Connection->__construct('/tmp/beanstalkd...', -1)
------
root@box:~/beans$ ls -l  /tmp/beanstalkd.sock
srwxr-xr-x 1 root root 0 Mar 27 06:21 /tmp/beanstalkd.sock

Is there a peek-buried command?

Hi

Is there peek-buried command in the library to query the buried jobs?

I looked at the BeansClient class and I can only see a Peak method but it expects job id.

I am using the version 2 code.

Reserving a job from an empty queue throws an "Unknown Error"

This is a bug report.

When reserving a job using $client->reserve();, an unknown error gets thrown when the queue is empty.

According to the documentation (and the source code), an empty queue should not throw an error, but instead result in a Job with id=null.

$client = new BeansClient(new Connection());
$client->watchTube('Project.Orders');
$job = $client->reserve(30);

// Exception: Unknown error in [/xobotyi/beansclient/src/Socket/SocketBase.php, line 158]
Stack Trace:
#0 /vendor/xobotyi/beansclient/src/Socket/SocketBase.php(175): xobotyi\beansclient\Socket\SocketBase->throwLastError()
#1 /vendor/xobotyi/beansclient/src/Connection.php(120): xobotyi\beansclient\Socket\SocketBase->readLine()
#2 /vendor/xobotyi/beansclient/src/BeansClient.php(76): xobotyi\beansclient\Connection->readLine()
#3 /vendor/xobotyi/beansclient/src/BeansClient.php(317): xobotyi\beansclient\BeansClient->dispatchCommand(Object(xobotyi\beansclient\Command\Reserve))
#4 /src/Command/OrdersCommand.php(30): xobotyi\beansclient\BeansClient->reserve(30)
[...]

Versions i'm using:

  • OS: OSX
  • PHP: 7.3.3
  • BeansClient: v1.0.1
  • beanstalkd: 1.11

Echo на клиенте

Как получить что то в echo на клиенте до того как завершит работу воркер?
Клиент
$job = $beansClient->useTube('myAwesomeTube') ->put($data); echo "ok";
Воркер
$job = $beansClient->watchTube('myAwesomeTube') ->reserve(); if ($job) { $data1 = unserialize($job->payload); $job->release(BeansClient::DEFAULT_PRIORITY, 600);

echo "ok"; я получаю только через 10 минут, а как можно получить сразу?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.