【问题标题】:Laravel not sending PusherLaravel 不发送 Pusher
【发布时间】:2018-02-17 04:24:53
【问题描述】:

所以我正在使用 Laravel 设置推送器,但我无法让它发送消息。推送器调试控制台中未收到它们,因此错误必须在发送它们时出现。以下是您可能需要的任何信息来帮助我发现错误,因为我花了数小时试图修复它,但现在无法进一步了解。

我的 .env 文件中的相关信息:

BROADCAST_DRIVER=pusher
QUEUE_DRIVER=sync

PUSHER_APP_ID=iscorrect
PUSHER_APP_KEY=iscorrect
PUSHER_APP_SECRET=iscorrect

我的广播.php

    'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
            'cluster' => 'eu',
            'encrypted'=>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;

class HelloPusherEvent implements ShouldBroadcast 
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
 * Only (!) Public members will be serialized to JSON and sent to Pusher
**/
public $message;

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

/**
 * Get the channels the event should be broadcast on.
 *
 * @return array
 */
public function broadcastOn()
{
    return ['my-channel'];
}
}

最后是我应该触发事件的路线:

Route::get('/pusher', function() {
event(new App\Events\HelloPusherEvent('Hi there Pusher!'));
return "Event has been sent!";
});

我在访问 /pusher 时没有收到任何错误,但不幸的是我的 Pusher 调试控制台正在“等待事件”..

【问题讨论】:

    标签: laravel pusher


    【解决方案1】:

    尝试启用内置pusher client logging system

    【讨论】:

    • 当我按照上述步骤操作时,在打开我网站的任何页面时都会收到 ReflectionException (-1) "Class pusher does not exist"。
    • 这也发生了,当我现在要作曲家更新时。它给了我同样的 ReflectionException。但是,当我反转更改时,一切都会再次正常,考虑调用页面或更新作曲家。知道为什么吗?
    【解决方案2】:

    检查您的本地 apache / nginx 日志中是否显示“无法获取本地发行人证书”的消息。

    如果是这样,请在 PHP 配置中定义 curl.cainfo 的路径。

    文件可以下载here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-22
      • 2021-07-11
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 2019-10-22
      相关资源
      最近更新 更多