mercredi 24 avril 2019

How to fix 419 error with broadcasting auth

In my Laravel Framework 5.7 / Vuejs 2.6 I use jwt.auth and installing pusher

I check xsfr token for my page https://imgur.com/a/CveJ6jh but I got 419 error in http://local/broadcasting/auth request and open responce of this url I see page expired message.
In app/Events/NewMessage.php :

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use App\Message;

class NewMessage
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $message;
    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(Message $message)
    {
        $this->message= $message;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('messages.'.$this->message->to);
    }
    public function broadcastWith()
    {
        return ['messages' => $this->message];
    }

}

In routes/channels.php :

Broadcast::channel('messages.{id}', function ($user, $id) {
    dd($user->id, $id);
    return (int) $user->id === (int) $id;
});

But I do not see any debugging info from above.

I used pusher parameters from my prior app. I think they must be ok. Otherwise I would have different error ?

and in vue component :

mounted() {
    Echo.private(`messages.${this.customerRow.id}`)
        .listen('NewMessage', (e) => {
            this.hanleIncoming(e.message);
        });

What did I miss ?

Thanks!



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2XCX8v5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire