question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event not being triggered by Pusher.

See original GitHub issue

Hi,

I think the event listener for private channels is not functioning correctly. I have followed the documentation so far, but Pusher is not triggering the event listener. In pusher under the debug console, I can see that the data is present, which can be seen in the attached image.

I also am posting below the code the I am using, in case the mistake is on my side (which I don’t hope).

<?php

namespace App\Events\Chat;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class UserSendChatMessage implements ShouldBroadcast
{
    use SerializesModels, InteractsWithSockets;
    
    public $id;


    /**
     * UserSendChatMessage constructor.
     * @param $user
     * @param $message
     */
    public function __construct($id)
    {
        $this->id = $id
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel("conversation.{$this->id}");
    }

}
Echo.private('conversation.' + this.uniqueConversationId)
                        .listen('.App.Events.Chat.UserSendChatMessage', function (event) {
                            alert('here...');
                            console.log(event);
                        });
 Broadcast::channel('conversation.*', function ($user, $uniqueId) {
            // Security: not secure, yet.
            return true;
        });
screen shot 2016-12-21 at 2 31 51 am

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
driesvintscommented, Oct 31, 2018

Closing this issue because it’s already solved, old or not relevant anymore. Feel free to reply if you’re still experiencing this issue.

1reaction
JBlaakcommented, Dec 28, 2016

For me a dive into how listen differs from on provided the solution, it will first pass the event through the event formatter, which will add a namespace. https://github.com/laravel/echo/blob/master/src/channel/pusher-channel.ts#L89

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pusher App events not triggering - php - Stack Overflow
If the events aren't reaching Pusher, make sure the Pusher server time and your server time match or are within 599s of each...
Read more >
Pusher not triggering events form client side. #516 - GitHub
I just opened my app today to have a look. Tried few pusher calls but suddenly not working getting response error.
Read more >
PHP Pusher event was not being triggered - Muhammad Habib
Problem: I have installed php pusher using composer require pusher/pusher-php-server and i was testing pusher library to send live event but ...
Read more >
Pusher Channels Docs | What is an event?
The event is triggered either when the authorization endpoint returns a HTTP status code that is not 200 or if there is a...
Read more >
Publish Pusher events for new emails - Zapier
Within Pusher this is often referred to as "triggering an event" where you trigger an event on a channel. But this terminology is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found