framework: PusherBroadcaster exception "Failed to connect to Pusher" when running in queue

  • Laravel Version: 5.3.23
  • PHP Version: 5.6.15
  • Database Driver & Version: MySql 5.6.31
  • OS : Windows 8.1 64bits

Description:

I’m using the “broadcast” notification channel to notify the user via pusher.

When not using queue or using queue with the sync driver every thing works as expected, and i receive the notification. But when i use the database driver for queues, the app can’t connect to pusher. This is the log.

local.ERROR: exception 'Illuminate\Broadcasting\BroadcastException' with message 'Failed to connect to Pusher.' in F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Broadcasting\Broadcasters\PusherBroadcaster.php:105
Stack trace:
#0 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Broadcasting\BroadcastEvent.php(53): Illuminate\Broadcasting\Broadcasters\PusherBroadcaster->broadcast(Array, 'Illuminate\\Noti...', Array)
#1 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(73): Illuminate\Broadcasting\BroadcastEvent->fire(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#2 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(201): Illuminate\Queue\Jobs\Job->fire()
#3 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(152): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#4 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(76): Illuminate\Queue\Worker->runNextJob('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#5 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(101): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#6 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#7 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#8 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Container\Container.php(508): call_user_func_array(Array, Array)
#9 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Console\Command.php(169): Illuminate\Container\Container->call(Array)
#10 F:\wamp3\www\opendata\vendor\symfony\console\Command\Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Console\Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 F:\wamp3\www\opendata\vendor\symfony\console\Application.php(820): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 F:\wamp3\www\opendata\vendor\symfony\console\Application.php(187): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 F:\wamp3\www\opendata\vendor\symfony\console\Application.php(118): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 F:\wamp3\www\opendata\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(121): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 F:\wamp3\www\opendata\artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 {main}  

Edit: I’m also using the mail and database channels in the same notification. These two always work, even from the queue with database driver.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 27 (2 by maintainers)

Most upvoted comments

A bit late, but you could just disable the encrypted options.

'options' => [
    'cluster' => 'eu',
    'encrypted' => false
]

So pusher will allow http calls but it’s not recommended for production use.

Yeah i solved it, you need to download curl certificate and point to it in your php.ini

When sending data to pusher, using the sync queue driver or no queue at all the php.ini file within your apache installation will be used. Because your request is coming from the web server. (HTTP)

When sending data to pusher, using any other queue driver the php.ini within php installation will be used. Because your request is coming from the console.

For me, the problem was that i added the certificate in the php.ini used by apache server, and didn’t add it in php.ini within the php.x.x.x/bin, so you just need to make sure that your add the certificate in both php.ini files.

You can download the certificate from https://curl.haxx.se/ca/cacert.pem

Then in both php.ini files search for this curl.cainfo and set the value to where your certificate is

For me it’s something like this :

[curl]
curl.cainfo = "F:\wamp3\bin\php\php5.6.15\extras\ssl\cacert.pem"

Screenshot 2020-04-18 at 10 39 11 AM You can setup a dummy route and check phpinfo and see if the cafile and path is set correctly like it says in the comment #16478

So in my case in the web.php file i do Route::get(‘/info’, function(){ phpinfo(); }) just to ensure php is picking the settings from the php.ini file.

I have same issue, and solved with sudo ntpdate ntp.ubuntu.com

error (“exception”:"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): at C:\projects\demo_socket_laravel\laravel_5_5_cdn\vendor\laravel\framework\src\Illuminate\Broadcasting\Broadcasters\PusherBroadcaster.php:107) laravel version : 5.5

i think trying to pusher version downgrade & try to this command (composer require pusher/pusher-php-server “3.0.0”)

this is working

@mariembenslama this comment should help you https://github.com/laravel/framework/issues/16478#issuecomment-615307814 So try it out fully. You may have to change some directory paths but certainly, ideas from this would go a long way in helping; that is if the issue you are having is as a result of curl not correctly verifying the host from which the secured request to pushers servers is coming from.

PHP

Yes I found it in /etc/ ^^ I’ll try the solution and tell you

I have fedora 29, and I couldn’t find the php.ini file You would have to find the php.ini , what output does your terminal give when you do PHP --ini

@mariembenslama have you tried the post above ?