Exception `ErrorException` thrown: `Undefined property: stdClass::$auth`
I'm getting this error after upgraded to Laravel 9.0
Exception 'ErrorException' thrown: 'Undefined property: stdClass::$auth' 950546: exception 'ErrorException' thrown: 'Undefined property: stdClass::$auth'.
I'm using Laravel 9 with inertia and vue2
I also get this error while trying to implement private channels.
Connection id 939293757.162424194 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"939293757.162424194\",\"activity_timeout\":30}"}
qwersda: connection id 939293757.162424194 received message: {"event":"pusher:subscribe","data":{"channel":"private-new_tenant_registry.77Csfg6AYYeawtL5maeTcjEhnwQ2"}}.
Exception `ErrorException` thrown: `Undefined property: stdClass::$auth`
qwersda: exception `ErrorException` thrown: `Undefined property: stdClass::$auth`.
- laravel-websockets v1.13.1
- laravel v9.6
- pusher-php-server v7.0.2
- PHP 8.1.4
- default guard web
- using passport as api authentication (auth:api)
same here any help?
websocket log
PUSHER_ID_1: connection id 961913920.471627343 received message: {"event":"pusher:subscribe","data":{"channel":"private-user.1"}}.
Exception `ErrorException` thrown: `Undefined property: stdClass::$auth`
PUSHER_ID_1: exception `ErrorException` thrown: `Undefined property: stdClass::$auth`.
.env
BROADCAST_DRIVER=pusher
CACHE_DRIVER=redis
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
SESSION_LIFETIME=120
channels.php

event

caller

frontend nuxt v2.15

after reading the codebase and can't find any leads and decided to take a sleep
finally i got it working by following the version dep based on beyondcode/laravel-websockets-demo#22 , here's my final set up.
@wrtisans @subooom
Auth by Laravel Passport
composer
"php": "^8.0",
"beyondcode/laravel-websockets": "^1.13",
"laravel/framework": "^9.0",
"pusher/pusher-php-server": "^7.0"
nuxt package.json
"laravel-echo": "^1.11.4",
"nuxt": "^2.9.0",
"pusher-js": "7.0.3",
BroadcastServiceProvider
public function boot()
{
// Broadcast::routes();
Broadcast::routes(['middleware' => ['web', 'api', 'auth:api']]);
require base_path('routes/channels.php');
}
vue method
window.echo = new Echo({
broadcaster: 'pusher',
key: this.$config.WS_KEY, // key
wsHost: this.$config.WS_HOST, // localhost
wsPort: this.$config.WS_PORT, // 3003
forceTLS: this.$config.WS_FORCE_TLS, // false
disableStats: true,
authEndpoint: `${this.$config.BASE_URL}/broadcasting/auth`,
auth: {
headers: {
Authorization: `Bearer ${window.localStorage.getItem(
'token_access'
)}`,
},
},
})
window.echo
.private('user.' + this.user.data.id)
.listen('.testing_private', (e) => {
console.log(e)
this.privateMessages.push(e.message)
})
I found a solution
Check some configuration
- Is
BroadcastServiceProviderinconfig/app.phpcommented out or not - Is
BROADCAST_DRIVERin.envset topushercorrectly
Also, check the auth endpoint returning auth json or not, if it does, it should work!
Auth JSON response format should like this:
auth: "test_key:881d12c1ca9453bbe080782ddda74f2ec5582c852a0e7251eb40263b818f549d"