Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda