Laravel 广播没有被触发

Laravel broadcast doesnt get triggered

尝试在好友请求 made.using pusher,vuejs 2.6,laravel 5.7 后将用户列表发送给特定用户,但在我的函数中,广播没有被触发

当我在频道中执行 dd 时,它起作用了!也在构造函数中。所以我有点困惑广播本身是否被调用但我没有看到列表的第二个 XHR 请求或其他一些情况!!?

//Boostrap.js
 import Echo from 'laravel-echo'
 window.Pusher = require('pusher-js');
 window.Echo = new Echo({
  broadcaster: 'pusher',
  app_id: '7xxxx4',
  key: 'xxxxxxxxxxxxxxxxxxx',
  secret: 'xxxxxxxxxxxxxxxxxxx',
   encrypted: false
    });
//Vuejs component
    mounted(){    window.Echo.channel("newReq").listen(".newreq-list", e => {
            this.getrequestedList();
        });
.env
BROADCAST_DRIVER=pusher

PUSHER_APP_ID=7xxxxx4
PUSHER_APP_KEY=xxxxxxxxxxxxxxxxxxx
PUSHER_APP_SECRET=xxxxxxxxxxxxxxxxxxx
PUSHER_APP_CLUSTER=ap2
Broadcasting.php
        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'encrypted' => false,
            ],
        ],
channels.php
 Broadcast::channel('newReq', function(){
        return true;
    });
<?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 Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;

class Friendreq implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

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

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('newReq');
    }
    public function broadcastAs()
    {
        return 'newreq-list';
    }
}
//in friendscontroller.php
         broadcast(new \App\Events\Friendreq($requestToadd)); 

我也取消了评论 App\Providers\BroadcastServiceProvider

对于结果,它应该调用函数 this.getrequestedList();,这是一个工作函数,因为它也在 created() 中调用 感谢您的帮助

调试2天,搜索很简单:

PUSHER_APP_CLUSTER=ap2

上面一行必须改成这个

PUSHER_APP_CLUSTER=eu

现在它被触发并按照我想要的方式工作