dqotv26286 2019-01-06 19:30
浏览 67

Pusher不适用于Linux AMI - AWS Elastic Beanstalk

I'm broadcasting events from Lumen 5.4 to Pusher. Everything works fine on my local machine, with PHP V7.0.22. However when I deploy my code to my Elastic Beanstalk instance running the same PHP version. Nothing happens.

Here is an example event I'm testing with;

Calling The Event

use App\Events\ExampleEvent;

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

    return "Complete";
});

Example Event

<?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';
    }
}

Again this works absolutely fine from localhost. I can see the events on the pusher debug console and also consume the messages on the front-end (Vue). However the exact same event does not fire from my EB instance (Linux AMI).

I'm using the below script to test pusher. Test Script

$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";
});

Unfortunately I get the same response on both local and server. 200 OK Response

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

The test event shows up in Pusher's debug console. But the same event does not emit when I broadcast via Laravel Event. There is no error when using Event Broadcasting but no result either.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 汇编语言除法溢出问题
    • ¥65 C++实现删除N个数据列表共有的元素
    • ¥15 Visual Studio问题
    • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗