1

I'm trying to set up a BeanStalkD client, using pheanstalk.

I can perform certain operations such as listTubes().

When I try and reserve a job off a beanstalkd queue I am getting the following error:

PHP Fatal error: Uncaught Pheanstalk\Exception\SocketException: Unknown error in C:\SmartParking\vendo r\pda\pheanstalk\src\Socket\FileSocket.php:49 Stack trace: #0 C:\SmartParking\vendor\pda\pheanstalk\src\Socket\FileSocket.php(91): Pheanstalk\Socket\FileSocket->t hrowException() #1 C:\SmartParking\vendor\pda\pheanstalk\src\Connection.php(84): Pheanstalk\Socket\FileSocket->getLine( ) #2 C:\SmartParking\vendor\pda\pheanstalk\src\Pheanstalk.php(372): Pheanstalk\Connection->dispatchComman d(Object(Pheanstalk\Command\ReserveCommand)) #3 C:\SmartParking\vendor\pda\pheanstalk\src\Pheanstalk.php(255): Pheanstalk\Pheanstalk->dispatch(Objec t(Pheanstalk\Command\ReserveCommand)) #4 C:\SmartParking\SecondAttempt.php(22): Pheanstalk\Pheanstalk->reserve() #5 {main} thrown in C:\SmartParking\vendor\pda\pheanstalk\src\Socket\FileSocket.php on line 49

What do I need to do to resolve this problem?

I've tried:

Various versions of PHP, various version of pheanstalk, restarting everything including the BeanStalkD server itself.

This is all running on a brand Windows Server 2016, PHP is just being used as a scripting engine off the command line.

I am using PHP version 7.2 currently.

// Hopefully you're using Composer autoloading.
require('vendor/autoload.php');
use Pheanstalk\Pheanstalk;
// Create using autodetection of socket implementation
$pheanstalk = Pheanstalk::create('127.0.0.1');

var_dump($pheanstalk->listTubes());

while(true){
  $job = $pheanstalk
  ->watch('alpr-alt')
  ->reserve();

  echo json_decode($job->getData(), true);
}
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
John McAulay
  • 185
  • 9
  • a little help investigating: in pheanstalk/FileSocket.php this `fgets($this->socket, 8192);` resolves to false and then throws that 'unknown Error' – Jeff Mar 28 '19 at 15:37
  • 1
    Thanks man, that really helped me out. I looked into this code and then realized I didn't have the sockets extension enabled in my PHP.ini. I feel like a real idiot now. I wasted 2 hours on this problem :) – John McAulay Mar 28 '19 at 15:59
  • You could write an answer to your own question with detailed explanation what solved that issue. Could help future visitors. – Jeff Mar 28 '19 at 16:04

1 Answers1

0

I didn't have sockets enabled in my PHP.ini

So I changed :

;extension=sockets

to

extension=sockets

If you're using PHP as part of a web server you'd have to restart it at this point.

And this fixed my problem.

Jeff
  • 6,895
  • 1
  • 15
  • 33
John McAulay
  • 185
  • 9