Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aarontharker's avatar

cURL error when broadcasting an event.

I'm trying to broadacast an event via Soketi. My frontend is connected with soketi and is communicating fine but when I try to broadcast an event from the backend it is trying to go to a different server. The error I'm getting in my logs is -

[2023-11-26 04:20:27] local.ERROR: Pusher error: cURL error 7: Failed to connect to 34.102.180.20 port 6001 after 21049 ms: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://34.102.180.20:6001/apps/999999/events?auth_key=225328dd0faabeda0bb6&auth_timestamp=1700972406&auth_version=1.0&body_md5=c2c69df78c870f01845db6682ef07322&auth_signature=e1710ee0b4c7e0a077347264ed1917db25365f9e1706e905e098c601e8eba599. {"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): Pusher error: cURL error 7: Failed to connect to 34.102.180.20 port 6001 after 21049 ms: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://34.102.180.20:6001/apps/999999/events?auth_key=225328dd0faabeda0bb6&auth_timestamp=1700972406&auth_version=1.0&body_md5=c2c69df78c870f01845db6682ef07322&auth_signature=e1710ee0b4c7e0a077347264ed1917db25365f9e1706e905e098c601e8eba599. at /app/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:164)
[stacktrace]
#0 /app/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php(92): Illuminate\Broadcasting\Broadcasters\PusherBroadcaster->broadcast(Object(Illuminate\Support\Collection), 'new-submission', Array)
#1 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Broadcasting\BroadcastEvent->handle(Object(Illuminate\Broadcasting\BroadcastManager))
#2 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#3 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#4 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#5 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#6 /app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\Container\Container->call(Array)
#7 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#8 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#9 /app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#10 /app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(123): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Broadcasting\BroadcastEvent), false)
#11 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#12 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#13 /app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(122): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#14 /app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Broadcasting\BroadcastEvent))
#15 /app/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#16 /app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(439): Illuminate\Queue\Jobs\Job->fire()
#17 /app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(389): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#18 /app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(176): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#19 /app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(137): Illuminate\Queue\Worker->daemon('redis', 'default', Object(Illuminate\Queue\WorkerOptions))
#20 /app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(120): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default')
#21 /app/vendor/laravel/horizon/src/Console/WorkCommand.php(51): Illuminate\Queue\Console\WorkCommand->handle()
#22 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Laravel\Horizon\Console\WorkCommand->handle()
#23 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#24 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#25 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#26 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#27 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\Container\Container->call(Array)
#28 /app/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php(326): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#29 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#30 /app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(1081): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Laravel\Horizon\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(201): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#34 /app/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 {main}

but as you can see from my env file I'm using localhost

PUSHER_APP_ID=fnp
PUSHER_APP_KEY=FNP2023
PUSHER_APP_SECRET=************
PUSHER_HOST=localhost
PUSHER_PORT=6001
PUSHER_SCHEME=http
#PUSHER_APP_CLUSTER=api
0 likes
4 replies
LaryAI's avatar
Level 58

It seems like your Laravel application is not using the environment variables you've set for the Pusher configuration. This can happen if the configuration is cached or if there's a misconfiguration in your broadcasting settings.

Here's what you can do to troubleshoot and fix the issue:

  1. Clear Configuration Cache: Run the following command to clear the configuration cache. This will ensure that your latest .env file settings are being used.

    php artisan config:clear
    
  2. Check Broadcasting Configuration: Open your config/broadcasting.php file and make sure that the pusher connection is set up to use the environment variables correctly. It should look something like this:

    'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'useTLS' => env('PUSHER_SCHEME') === 'https',
            'host' => env('PUSHER_HOST'),
            'port' => env('PUSHER_PORT'),
            'scheme' => env('PUSHER_SCHEME'),
        ],
    ],
    

    Make sure that the PUSHER_APP_CLUSTER is commented out or removed if you are not using a cluster.

  3. Verify Environment Variables: Ensure that your .env file is on the server where your Laravel application is running and that it has the correct permissions to be read by the application.

  4. Check Soketi Configuration: If you are using Soketi, make sure that it is configured correctly and running on the specified host and port.

  5. Test Connection: You can test the connection to your Soketi server using telnet or a similar tool to ensure that the server is reachable from your Laravel application server.

    telnet localhost 6001
    

    If the connection is successful, you should be able to establish a connection. If not, you'll need to troubleshoot the network connectivity or Soketi server configuration.

  6. Restart Queue Worker: If you are using Laravel queues to handle your event broadcasting, make sure to restart the queue worker after making changes to the configuration:

    php artisan queue:restart
    

    This will ensure that the worker is using the latest configuration settings.

By following these steps, you should be able to resolve the cURL error when broadcasting an event with Soketi. If the problem persists, double-check your network settings and ensure that there are no firewalls or security groups blocking the connection to the Soketi server.

aarontharker's avatar

ok I've done both the config:clear and queue:reset and my broadcasting.php is as follows -

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY', 'app-key'),
            'secret' => env('PUSHER_APP_SECRET', 'app-secret'),
            'app_id' => env('PUSHER_APP_ID', 'app-id'),
            'options' => [
               'host' => env('PUSHER_HOST', '127.0.0.1'),
               'port' => env('PUSHER_PORT', 6001),
               'scheme' => env('PUSHER_SCHEME', 'http'),
               'encrypted' => true,
               'useTLS' => env('PUSHER_SCHEME') === 'https',
            ],
        ],
Quobec's avatar

For me it was the driver. After running php artisan config:show broadcasting I saw:

default ................................................................................................................................... reverb
connections ⇁ reverb ⇁ driver ............................................................................................................. reverb

In .env I changed

BROADCAST_CONNECTION=reverb

to

BROADCAST_CONNECTION=pusher

Please or to participate in this conversation.