You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my laravel app I'm getting the following error message from Pusher, i'm a bit lost on what the error exactly means bit it seems to be triggered on this Pusher method:
So apparently the problem is I'm passing an array instead of an object or class, the thing is I'm using laravel broadcast method to trigger events on my app, this works on local but for production is giving me this error for some reason...
broadcast(new NewChatEvent())
My event:
class NewChatEvent implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $data;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
//return new Channel('chat.receiver.1');
return new Channel('chat.receiver.'.$this->data['receiver']['id']);
}
}
```
And my channels file:
```
<?php
use Illuminate\Support\Facades\Broadcast;
use App\Models\User;
use App\Models\Chat;
/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/
Broadcast::channel('chat.receiver.{id}', function ($user, $id) {
//return (int) $user->id === (int) $id;
return true;
});
```
The full error is here:
```
[2023-09-03 23:39:53] production.ERROR: First parameter must either be an object or the name of an existing class {"exception":"[object] (ErrorException(code: 0): First parameter must either be an objec
t or the name of an existing class at /var/www/laraapp.com/vendor/pusher/pusher-php-server/src/Pusher.php:538)
[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'First parameter...', '/var/www/woolov...', 538, Array)
#1 /var/www/laraapp.com/vendor/pusher/pusher-php-server/src/Pusher.php(538): property_exists(NULL, 'channels')
#2 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php(125): Pusher\Pusher->trigger(Array, 'App\\
Events\\NewC...', Array, Array)
#3 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php(77): Illuminate\Broadcasting\Broadcasters\PusherBroadcaster->broadcast(Array, 'App\\Events\\NewC...', Array)
#4 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Broadcasting\BroadcastEvent->handle(Object(Illuminate\Broadcasting\BroadcastManager))
#5 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#6 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#7 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#8 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#9 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\Container\Container->call(Array)
#10 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#11 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#12 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#13 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php(119): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Broadcasting\BroadcastEvent))
#14 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(320): Illuminate\Broadcasting\BroadcastManager->queue(Object(App\Events\NewChatEvent))
#15 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(243): Illuminate\Events\Dispatcher->broadcastEvent(Object(App\Events\NewChatEvent))
#16 /var/www/laraapp.com/vendor/laravel/framework/src/Illuminate/Broadcasting/PendingBroadcast.php(72): Illuminate\Events\Dispatcher->dispatch('App\\Events\\NewC...')
#17
```
How can I fix this?
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you'd like this issue to stay open please leave a comment indicating how this issue is affecting you. Thank you.
In my laravel app I'm getting the following error message from Pusher, i'm a bit lost on what the error exactly means bit it seems to be triggered on this Pusher method:
So apparently the problem is I'm passing an array instead of an object or class, the thing is I'm using laravel broadcast method to trigger events on my app, this works on local but for production is giving me this error for some reason...
My event:
The text was updated successfully, but these errors were encountered: