Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Unable to receive notifications via Echo using laravel-websockets

When I connect via Channel instead of PrivateChannel, everything works as expected. But when I connect via PrivateChannel, I suddenly stop receiving events inside my javascript My events appear inside the WebSocket dashboard. I dispatch my event like this:

            FullRecipeSaved::dispatch($recipe, $rld);

FullRecipeSaved.php


class FullRecipeSaved implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $recipe;

    public $recipeLiftingDate;

    public function __construct(Recipe $recipe, RecipeLiftingDate $recipeLiftingDate)
    {
        $this->recipe = $recipe;
        $this->recipe = $recipeLiftingDate;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('recipe');
    }

    /**
     * The event's broadcast name.
     *
     * @return string
     */
    public function broadcastAs()
    {
        return 'recipe.update';
    }
}

channels.php

<?php

Broadcast::channel('recipe', function($recipe, $recipeLiftingDate) {
    return true;
});

bootstrap.js

window.Echo = new Echo({
    broadcaster: "pusher",
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    wsHost: window.location.hostname,
    wsPort: 6001,
    forceTLS: false,
    disableStats: false,
    authEndpoint: GLOBAL.appUrl,
});

The GLOBAL.appUrl is the APP_URL from .env filehttp://localhost/****/public). And this is the code I am using to connect to the channel

window.Echo.private("recipe").listen(
        ".recipe.update",
        (event) => {
            console.log("ok");
        }
    );
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!