Giter VIP home page Giter VIP logo

Comments (9)

w00key avatar w00key commented on May 14, 2024 2

You can override the driver with a custom one that accepts the additional client_options added.
Also verify needs to be false.

In your BroadcastServiceProvider:

    public function boot(BroadcastManager $broadcastManager)
    {
        Broadcast::routes();

        $broadcastManager->extend('pusher', function($app, $config) {
            $pusher = new Pusher(
                $config['key'], $config['secret'],
                $config['app_id'], $config['options'] ?? [],
                new \GuzzleHttp\Client($config['client_options']) ?? []
            );
    
            if ($config['log'] ?? false) {
                $pusher->setLogger($this->app->make(LoggerInterface::class));
            }
    
            return new PusherBroadcaster($pusher);
        });

        require base_path('routes/channels.php');
    }

from soketi.

rennokki avatar rennokki commented on May 14, 2024 1

@francoism90 I think that having Pusher 6.x+ and passing a client instance when creating the Pusher\Pusher instance is much better than extending the entire class :)

  • Add this to broadcasting:
    'options' => [
        // ...
    ],
    'client_options' => [
        'verify' =>true, // to disable TLS checks
    ],
  • Extend the Illuminate\Broadcasting\BroadcastManager to create Pusher with client options:
namespace App;

use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
use Illuminate\Broadcasting\BroadcastManager as BaseBroadcastManager;
use Psr\Log\LoggerInterface;
use Pusher\Pusher;

class TlsSupportingBroadcastManager extends BaseBroadcastManager
{
    protected function createPusherDriver(array $config)
    {
        $pusher = new Pusher(
            $config['key'], $config['secret'],
            $config['app_id'], $config['options'] ?? [],
            new \GuzzleHttp\Client($config['client_options']) ?? []
        );

        if ($config['log'] ?? false) {
            $pusher->setLogger($this->app->make(LoggerInterface::class));
        }

        return new PusherBroadcaster($pusher);
    }
}
  • Re-instantiate the BroadcastManager at runtime:
namespace App\Providers;

use App\TlsSupportingBroadcastManager;

class BroadcastingServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(BroadcastManager::class, function ($app) {
            return new TlsSupportingBroadcastManager($app);
        });
    }
}

from soketi.

rennokki avatar rennokki commented on May 14, 2024 1

@francoism90 It seems like it got merged in 9.x. Until then, I hope the workaround works.

from soketi.

francoism90 avatar francoism90 commented on May 14, 2024 1

@rennokki Great news! I'll wait for Laravel 9 and use Pusher v5 for now. :)

from soketi.

w00key avatar w00key commented on May 14, 2024 1

Yes it works on laravel 8 with verify set to false, I did state that maybe I should have highlighted that. I did try various approaches to overriding the singleton with little success. This works by providing the broadcast manager a custom driver and because the broadcast manager looks for custom driver first, you can keep the same driver name.

from soketi.

francoism90 avatar francoism90 commented on May 14, 2024

pusher/pusher-http-php#313

Seems downgrading is the only way? :(

from soketi.

francoism90 avatar francoism90 commented on May 14, 2024

@rennokki Thanks for your workaround and details how to use it!

I'll wait if proposed PR is going to be merged, otherwise I'll implement this solution. :)

from soketi.

francoism90 avatar francoism90 commented on May 14, 2024

@w00key This seems to work (local) on Laravel 8 using verify' => false. :)

from soketi.

LingaTigeen avatar LingaTigeen commented on May 14, 2024

Refer beyondcode/laravel-websockets#879 (comment)

from soketi.

Related Issues (20)

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.