Turns out that all it was was I needed a fresh install of Laravel 5.3, after install of a fresh copy, I copied and pasted everything across and worked perfectly. I assume I had a buggy build.
Great post @Encrypt !!!
Could you also post your UserHasRegistered Event class?
Is it required for pusher in this context?
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class UserHasRegistered implements ShouldBroadcast
{
use InteractsWithSockets, SerializesModels;
public $user;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($user)
{
$this->user = $user;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return ['test'];
}
}
Thanks,
I'm trying to get it work sincer yesterday with no succees. I'm stuck on private channel auth, the xhr request to broadcasting/auth from echo returns 500 Error. Any ideas on this @Encrypt ?
I figured it out.. It had to do with csrf_token.. Fixed.
Soooo..... should anyone read this thread and find nothing that works, here's what solved it for me: fixing the bloody time on my VM. It was off by 30 minutes.
Only after I created a plain Pusher model and inspected the curl response did I notice a 401 error code! For some reason or another laravel doesn't throw an exception when it fails.
Hope it helps someone!
We ran into this problem running laravel in a subdirectory. Found that defining the default authEndpoint value in the Echo setup, fixed it for us.
"/broadcasting/auth", => "broadcasting/auth"
The leading "/" is removed.
window.Echo = new Echo({ authEndpoint: "broadcasting/auth", broadcaster: 'pusher', key: '---888---', cluster: '---888---', encrypted: true });
@joseph127 The issue you could be having back then could be due to the namespace(s). Thats why when you re generated the app, everything worked out of the box. Any one else going through something similar, make sure the namespaces are set right for the events, and in Echo.
Please or to participate in this conversation.