Bvanhaastrecht's avatar

Laravel-websockets not receiving the broadcast

Hello,

I have upgraded from 8 to 9, after the upgrade the broadcasting got broken. I have laravel-websockets running locally and the broadcasting configuration was targeting the localhost. Because of laravel-pusher removed the curl_options, I can no longer use these two options:

CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,

So I now have two options. I first tried the workaround by creating a custom broadcast with again those curl options and still target the localhost. When triggering broadcast messages, I got no errors but the messages were not received by laravel-websockets.

Then I decided to no longer target the localhost but use the public proxy. We have a proxy configured which allows public access to the laravel-websockets. Again, when triggering broadcast messages, they are not reveived by laravel-websockets.

In both situations I do see ping:pong traffic coming back and forth from the browser. I do not get any errors on Laravel side when I trigger a broadcast.

Things tried:

  • It doesnt matter if U use ShouldBroadcastNow or ShouldBroadcast.
  • Updated npm laravel-echo and pusher-js to latest versions. (While I do not think this is a front-end issue)

Broadcast message

class SendMessageToUser implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $broadcastQueue = 'priority';
    public $user;
    public $message;
    public $result;
    public $data;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($user, $message, $result = 'info', $data = null)
    {
        $this->user = $user;
        $this->message = $message;
        $this->result = $result;
        $this->data = $data;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('user.' . $this->user->id);
    }

    public function broadcastWith()
    {
        return [
            'result' => $this->result,
            'message' => $this->message,
            'data' => $this->data
        ];
    }
}

Does anyone have an idea what could be going wrong?

0 likes
1 reply

Please or to participate in this conversation.