georgeboot / laravel-echo-api-gateway

Use Laravel Echo with API Gateway Websockets. Works with Bref.sh and Laravel Vapor.
MIT License
99 stars 23 forks source link

Argument #1 ($result) must be of type array, Aws\Result given #19

Open Caceres-Joseph opened 2 years ago

Caceres-Joseph commented 2 years ago

Hi @georgeboot

I have created a route for call the broadcast like this

# web.php

Route::get('/broadcast', function () {
    broadcast(new Hello());
});

This is my event

/app/Events/Hello.php

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

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

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    public function broadcastWith()
    {
        return [
            'hello' => 'hi there'
        ];
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('channel');
    }
}

I already checked that the lambda has permissions for the DynamoDB table but I noticed that the Dynamo table is empty, that could be why I get this error when calling the event

image

Do you know what could be?

Thanks

NairanOmura commented 2 years ago

Hello,

I had the same problem and i opened a pull-request to resolve this... #20

the return of AWS library is "/Aws/Result", this package accepts only "array". to resolve temporarily in my projects i add the following command in my pipelines:

sed -i 's,(array $result):\ array,($result),g' vendor/georgeboot/laravel-echo-api-gateway/src/SubscriptionRepository.php

this solved it for me until it fixed it definitively