Pusher在Linux AMI上不起作用-AWS Elastic Beanstalk

问题描述 投票:0回答:1

我正在将事件从Lumen 5.4广播到Pusher。使用PHP V7.0.22,一切都可以在我的本地计算机上正常运行。但是,当我将代码部署到运行相同PHP版本的Elastic Beanstalk实例时。什么都没发生。

这是我正在测试的示例事件;

调用事件

use App\Events\ExampleEvent;

$app->get('/event', function(){  
    $message = "Hello Haseeb";
    event(new ExampleEvent($message));

    return "Complete";
});

示例事件

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel;

class ExampleEvent extends Event
{
    public $message;

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

    public function broadcastOn()
    {
        return new Channel('nai-btana');
    }

    public function broadcastAs() {
        return 'coolest-event-ever';
    }
}

同样,从localhost可以正常使用。我可以在Pusher调试控制台上看到事件,也可以在前端(Vue)上使用消息。但是,完全相同的事件不会从我的EB实例(Linux AMI)中触发。

我正在使用以下脚本来测试推送程序。测试脚本

$app->get('/event', function(){
    error_reporting(E_ALL);

    $app_id = env('PUSHER_APP_ID'); 
    $app_key = env('PUSHER_KEY');
    $app_secret = env('PUSHER_SECRET');

    class MyLogger {
        public function log( $msg ) {
            print_r( $msg . "<br />" );
        }
    }

    $pusher = new Pusher($app_key, $app_secret, $app_id, array( 'cluster' => 'ap2' ));
    $logger = new MyLogger();
    $pusher->set_logger( $logger );

    $data['message'] = 'hello world';
    $result = $pusher->trigger('simple', 'simple', $data);
    $logger->log( "---- My Result ---" );
    $logger->log( $result );

    return "Complete";
});

不幸的是,我在本地和服务器上都得到了相同的响应。 200 OK响应

Pusher: ->trigger received string channel "simple". Converting to array.
Pusher: create_curl( http://api-ap2.pusher.com:80/apps/674397/events?auth_key=277a5f98b54adff6fbff&auth_signature=13921666bca17192ef8fdb717d086f828428eef41ecbe9b13460e952ab4cf489&auth_timestamp=1546792861&auth_version=1.0&body_md5=93926a8b33af11740f1903f0a7102fbf )
Pusher: trigger POST: {"name":"simple","data":"{\"message\":\"hello world\"}","channels":["simple"]}
Pusher: exec_curl response: Array ( [body] => {} [status] => 200 ) 
---- My Result ---
1
Complete

测试事件显示在Pusher的调试控制台中。但是当我通过Laravel Event广播时,不会发出相同的事件。使用事件广播时没有错误,但也没有结果。

php lumen amazon-elastic-beanstalk pusher
1个回答
0
投票

相同的问题。您知道出了什么问题吗?

© www.soinside.com 2019 - 2024. All rights reserved.