laravel pusher-在生产上发送事件不起作用

时间:2020-07-13 19:07:49

标签: php laravel pusher

这是Im首次使用pusher(pusher.com),在本地但在生产上都可以正常发送通知,但是如果我从本地发送,它可以正常工作并向生产发送通知,但是从现场发送则无法正常工作! !!

广播:

       'pusher' => [
        'driver' => 'pusher',
        'key' => env('PUSHER_APP_KEY'),
        'secret' => env('PUSHER_APP_SECRET'),
        'app_id' => env('PUSHER_APP_ID'),
        'options' => [
        'cluster'=> env('CLUSTER'),
        'encrypted' => true,
        
        ],
    ],

发送功能:

 public function OrderEvent()
{
   

$order_number='150';

    event(new OrderSubmitted($order_number));
   return "We just sent!";
}

生产错误:

 production.INFO: Broadcasting [App\Events\OrderSubmitted] on channels [order-submitted] with payload:
 {
 "order_number": "15-EA",
 "socket": null
 }  

2 个答案:

答案 0 :(得分:1)

如果您没有在pusher上验证电子邮件,通常会发生

如果您已经这样做了,请确保已将其保存在配置文件中。 ( broadcasitng.php

      'options' => [
            'cluster' => 'ap2',
            'encrypted' => true
        ],

如果以上方法均无效,则很可能是您的主机名配置错误。 请记住从主机中排除http/https。不是https://example.com,而是example.com

'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' => true,
        'host' => env('PUSHER_HOST'),
        'port' => 6001,
        'scheme' => env('PUSHER_SCHEME')
    ],
],

和带有以下内容的.env文件:

PUSHER_HOST=example.com

答案 1 :(得分:0)

错误在于.env

BROADCAST_DRIVER=log should be pusher