Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cURL error when Broadcasting to Reverb #170

Closed
mvdgeijn opened this issue Apr 24, 2024 · 8 comments
Closed

cURL error when Broadcasting to Reverb #170

mvdgeijn opened this issue Apr 24, 2024 · 8 comments

Comments

@mvdgeijn
Copy link

Reverb Version

v1.0.0-beta7

Laravel Version

v11.4.0

PHP Version

8.3

Description

Homestead: 15.0.2 (parallels desktop)
Settler: v14.0.2
cURL: v7.81.0
Ubuntu: 22.04 / arm64

Sending a notification from our queue worker to Reverb, but while doing that, I get a cURL exception. I guess I can fix this by upgrading cURL, but I don't know how to do this in Homestead.

[2024-04-24 12:46:26] local.ERROR: Pusher error: cURL error 35: error:0A000126:SSL routines::unexpected eof while reading (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://ws.bhosted.lnl:6001/apps/1595941/events?auth_key=df29235abe86a6a56f97&auth_timestamp=1713955586&auth_version=1.0&body_md5=17f1f715f8dc0ca1e4b18b79dba4a070&auth_signature=32eb4bfe63c0a53e2b0692f802a6200ae851c0597db617f06f87ee8770c1b9ce. {"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): Pusher error: cURL error 35: error:0A000126:SSL routines::unexpected eof while reading (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://ws.bhosted.lnl:6001/apps/1595941/events?auth_key=df29235abe86a6a56f97&auth_timestamp=1713955586&auth_version=1.0&body_md5=17f1f715f8dc0ca1e4b18b79dba4a070&auth_signature=32eb4bfe63c0a53e2b0692f802a6200ae851c0597db617f06f87ee8770c1b9ce. at /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:164)
[stacktrace]
#0 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php(92): Illuminate\Broadcasting\Broadcasters\PusherBroadcaster->broadcast()
#1 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Broadcasting\BroadcastEvent->handle()
#2 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#3 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#4 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
#5 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call()
#6 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\Container\Container->call()
#7 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}()
#8 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#9 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then()
#10 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(124): Illuminate\Bus\Dispatcher->dispatchNow()
#11 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}()
#12 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#13 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(123): Illuminate\Pipeline\Pipeline->then()
#14 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(71): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware()
#15 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(102): Illuminate\Queue\CallQueuedHandler->call()
#16 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(439): Illuminate\Queue\Jobs\Job->fire()
#17 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(389): Illuminate\Queue\Worker->process()
#18 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(176): Illuminate\Queue\Worker->runJob()
#19 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(139): Illuminate\Queue\Worker->daemon()
#20 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(122): Illuminate\Queue\Console\WorkCommand->runWorker()
#21 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#22 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#23 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#24 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
#25 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\Container\BoundMethod::call()
#26 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Console/Command.php(212): Illuminate\Container\Container->call()
#27 /home/vagrant/code/bhosted/vendor/symfony/console/Command/Command.php(279): Illuminate\Console\Command->execute()
#28 /home/vagrant/code/bhosted/vendor/laravel/framework/src/Illuminate/Console/Command.php(181): Symfony\Component\Console\Command\Command->run()

Steps To Reproduce

Reinstalled the whole Homestead on a Macbook Air M3. Same problem.

@joedixon
Copy link
Collaborator

@mvdgeijn can you give this branch a try? #167

@mvdgeijn
Copy link
Author

Thanks, but that branch does not fix this error.

@joedixon
Copy link
Collaborator

How are you configuring the certificate within Homestead?

@mvdgeijn
Copy link
Author

mvdgeijn commented Apr 24, 2024

I created the pem file like this:

cd /etc/ssl/certs
sudo cat ca.homestead.homestead.crt ws.example.com.crt ws.example.com.key > /home/vagrant/code/project/storage/app/ssl/ws.example.com.pem

That file is included in the reverb.php config file:

...
    'servers' => [

        'reverb' => [
            'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
            'port' => env('REVERB_SERVER_PORT', 8080),
            'hostname' => env('REVERB_HOST'),
            'options' => [
                'tls' => [
                    'local_cert' => env('REVERB_TLS_PEM_FILE', '')
                ],
            ],
            'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
            'scaling' => [
                'enabled' => env('REVERB_SCALING_ENABLED', false),
                'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
            ],
            'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
        ],

    ],
...

Part of the .env file:

...

REVERB_TLS_PEM_FILE=/home/vagrant/code/project/storage/app/ssl/ws.example.com.pem

...

@mvdgeijn
Copy link
Author

I just noticed that with this branch of reverb I can not connect at all:

$ wget https://ws.example.com:6001
--2024-04-24 10:22:31--  https://ws.example.com:6001/
Resolving ws.example.com (ws.example.com)... 127.0.0.1
Connecting to ws.example.com (ws.example.com)|127.0.0.1|:6001... connected.
OpenSSL: error:0A000126:SSL routines::unexpected eof while reading
Unable to establish SSL connection.

With the reverb main branch installed I got a 404 / not found message.

@joedixon
Copy link
Collaborator

You will probably need to instruct Guzzle not to verify the cert as it won't be trusted.

You can do this by updating your broadcasting.php file as follows:

'reverb' => [
    'driver' => 'reverb',
    'key' => env('REVERB_APP_KEY'),
    'secret' => env('REVERB_APP_SECRET'),
    'app_id' => env('REVERB_APP_ID'),
    'options' => [
        'host' => env('REVERB_HOST'),
        'port' => env('REVERB_PORT', 443),
        'scheme' => env('REVERB_SCHEME', 'https'),
        'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
    ],
    'client_options' => [
        // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
+      'verify' => false,
    ],
],

Failing that, I would probably try mkcert instead to help create trusted certificates.

@mvdgeijn
Copy link
Author

I reverted back to the reverb beta8 version and first fixed the ssl issue. You were right: the created pem file was not correct (order of the private / public / ca keys was wrong). https://ws.example.com:6001 now results in the expected 404 message again.

Once fixed, I installed the reverb fix/openssl version again. Now https://ws.example.com:6001 results also in the 404 message. Did a first test, and it seems to have fixed the cURL error. Will test this further today and post an update later today.

P.S. If anyone wants to create their own certificate pem file in Homestead, the order should be private, public, ca:

sudo cat /etc/ssl/certs/ws.example.com.key /etc/ssl/certs/ws.example.com.crt /etc/ssl/certs/ca.homestead.homestead.crt > /home/vagrant/code/project/storage/app/ssl/ws.example.pem

@mvdgeijn
Copy link
Author

mvdgeijn commented Apr 25, 2024

@joedixon Did some more testing. Most cURL errors are gone with the fix/openssl version. There was one error, but that could be caused by a big payload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants