mirovit / nova-notifications

65 stars 26 forks source link

Hi, i have `"Invalid key in subscription auth data: 'PUSHER_APP_KEY'"` error. I only get notifications when i refreshed. #45

Open yahya077 opened 2 years ago

yahya077 commented 2 years ago

Hi, i have "Invalid key in subscription auth data: 'PUSHER_APP_KEY'" error. I only get notifications when i refreshed.

My Configuration;

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: '6ef4y8ax364544fd4188', //this is dummy key don't test it out.
    cluster: 'eu',
    encrypted: true
});

I changed key with something wrong key the displaying errors changed to "App key 6ef4d8ac354444fd4187 not in this cluster. Did you forget to specify the cluster?"

There is no console error but in the network console pin-pong doesn't look like working. I will add screenshot of messages of network down below (status code: 101) Screenshot from 2022-05-19 14-23-32

Originally posted by @yahya077 in https://github.com/mirovit/nova-notifications/issues/3#issuecomment-1131578238

mirovit commented 2 years ago

Hey @yahya077,

This seems to be issue with the Echo setup and Pusher, since this package doesn't do anything related to it, it's expected that the Laravel application is already configured properly.

Can you try to re-generate keys, make sure all configuration options are set in your .env file?

yahya077 commented 2 years ago

I didn't do anything but the pusher error has gone. But when I send notification it doesn't send to the client browser without refresh.

//my notification class

  return \Mirovit\NovaNotifications\Notification::make()
      ->info('Info message')
      ->subtitle('This is subtitle')
      ->routeDetail('orders',$this->order->id)
      ->toArray();

//my User Class
    public function sendOrderNotification($order): void
    {
        $this->notify(new OrderNotification($order));
    }

If i tried to send manually from browser it send to the pusher.


//I can see this in pusher debug console but I can't see if i push with \Mirovit\NovaNotifications\Notification

Echo.private('App.Models.Admin.4').whisper('typing',{name: "test name"});
yahya077 commented 2 years ago

I fixed issue removing these configs;

'host' => env('PUSHER_APP_HOST'),
'port' => env('PUSHER_APP_PORT'),

After that notification works.

But sometimes my notifications not send to the pusher. The error log is;

Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [App\Models\Admin]. in /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:517

And sometimes the error is;

Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "App\Notifications\OrderNotification" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in /var/www/vendor/laravel/framework/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php:57

mirovit commented 2 years ago

Hey @yahya077,

It's good to hear that your issue is resolved. My thoughts were in the direction of configuration, as the package itself doesn't handle the communication with Pusher or the socket server used.

For this Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [App\Models\Admin]. in /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:517 -> this is probably due to the user setup, check your setup for the authentication of the broadcasting channels in routes/channels.php, if you are using findOrFail this exception will get triggered and you need to handle it.

For the other issue, I haven't seen it before, but it seems like it might be something in you dev setup?