broadcast notification failed with curl error 3 - malformed url

I'm having trouble getting the broadcast notifications working. I'm getting an error in Illuminate\Notifications\Events\BroadcastNotificationCreated. Looking in dev tools, this is what I see as the first part of the URL: https://sockjs-${pusher_app_cluster}.pusher.com/pusher/app config/filament.php has these keys that I don't have values for in my .env file and nothing is mentioned about them in the docs:
'wsHost' => env('VITE_PUSHER_HOST'),
'wsPort' => env('VITE_PUSHER_PORT'),
'wssPort' => env('VITE_PUSHER_PORT'),
'wsHost' => env('VITE_PUSHER_HOST'),
'wsPort' => env('VITE_PUSHER_PORT'),
'wssPort' => env('VITE_PUSHER_PORT'),
Can anyone give me some guidance on what might be going wrong?
Solution:
Was able to fix this by commenting out some of the variables in the broadcasting config built into laravel. Doesn't make sense, but it's working. i'll take the win and move on.
No description
Jump to solution
24 Replies
Jon Mason
Jon Mason8mo ago
It looks as if Laravel Echo references a PUSHER_APP_CLUSTER and it wasn't seeing that, so I changed VITE_PUSHER_APP_CLUSTER to just PUSHER_APP_CLUSTER, and now I'm getting a different error: Access to XMLHttpRequest at 'https://sockjs-us2.pusher.com/pusher/app/...' from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Was able to at least get something going to pusher and I can see it in the debug console, but I'm getting a 404 response that's triggered at /Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:169 Looks like filament is adding an EchoLoaded event, so I copied that over to my blade file to try and see what's coming back, which kind of works: <script> window.addEventListener('EchoLoaded', (event) => { console.log(event); <--logs value console.log('EchoLoaded'); <--logs value window.Echo.private('App.Models.User.1').listen('.database-notifications.sent', () => { console.log('database-notifications.sent') <--never gets here }) }) </script> Seems like it's not "hearing" the .database.notifications.sent event. I would think that filament already handles the event listener and displaying the notification, so i must be missing something. Bump. Can anyone assist with broadcast notification?
Quin.
Quin.8mo ago
Can you show your filament Notification code for this
Jon Mason
Jon Mason8mo ago
I'm just doing this inside of a job as a simple example from the docs:
Notification::make()
->title('Saved successfully')
->broadcast(Auth::user());
Notification::make()
->title('Saved successfully')
->broadcast(Auth::user());
I can see in pusher that it's getting the connection
No description
Jon Mason
Jon Mason8mo ago
It doesn't seem to be sending the actual notification though.
Jon Mason
Jon Mason8mo ago
I'm getting: Illuminate\\Broadcasting\\BroadcastException(code: 0): Pusher error: not found
Jon Mason
Jon Mason8mo ago
These are my settings in config/filament.php
'broadcasting' => [

'echo' => [
'broadcaster' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'cluster' => env('PUSHER_APP_CLUSTER'),
'wsHost' => env('PUSHER_HOST'),
'wsPort' => env('PUSHER_PORT'),
'wssPort' => env('PUSHER_PORT'),
'authEndpoint' => '/broadcasting/auth',
'disableStats' => true,
'encrypted' => false,
],

],
'broadcasting' => [

'echo' => [
'broadcaster' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'cluster' => env('PUSHER_APP_CLUSTER'),
'wsHost' => env('PUSHER_HOST'),
'wsPort' => env('PUSHER_PORT'),
'wssPort' => env('PUSHER_PORT'),
'authEndpoint' => '/broadcasting/auth',
'disableStats' => true,
'encrypted' => false,
],

],
and then in my config/broadcasting.php:
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'port' => env('PUSHER_PORT', 80),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => false,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'port' => env('PUSHER_PORT', 80),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => false,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
Quin.
Quin.8mo ago
and your .env file is filled in the right way? all the keys that all
Jon Mason
Jon Mason8mo ago
I think so...
No description
Jon Mason
Jon Mason8mo ago
i think pusher host might be wrong actually.. i don't think that's my host, i think that's the pusher host...? i commented that out and it didn't do anyhing, so i guess not. the last project I had (not filament) i had pusher working and never defined a host or a port. maybe those have to be there for filament though. In the config/filament.php file there are no defaults and I'm assuming that overrides the broadcasting.php config file.
Quin.
Quin.8mo ago
you don't need the host in your .env and port also isn't needed but your data comes in your pusher right?
Jon Mason
Jon Mason8mo ago
Not sure I'm following, I can log the data up to the point that it's sent to pusher and I can see the filament notifcation data and everything, but in my log file I'm getting an HTML document as a response and in that document it's indicating a 404 error. I find it odd that it's sending back an HTML document.
Jon Mason
Jon Mason8mo ago
I removed host and port from my env file, ran composer dump-autoload and artisan optimize:clear and i'm still getting the same error.
Quin.
Quin.8mo ago
yeah that wouldn't be the problem but it isn't needed. sooooo do you have a job where you do the notification or where do you trigger it and when
Jon Mason
Jon Mason8mo ago
yeah it's in a job, I'm basically just doing this:
try {
$user = User::find(1);
Notification::make()
->title('Saved successfully')
->broadcast($user);


} catch (Throwable $e) {
Log::debug($e->getMessage());
}
try {
$user = User::find(1);
Notification::make()
->title('Saved successfully')
->broadcast($user);


} catch (Throwable $e) {
Log::debug($e->getMessage());
}
Quin.
Quin.8mo ago
can you look in your database then the table failed_jobs and can you send the error
Jon Mason
Jon Mason8mo ago
{"uuid":"b5d32508-0c8c-4740-aecd-a7886d1e096a","displayName":"Illuminate\Notifications\Events\BroadcastNotificationCreated","job":"Illuminate\Queue\CallQueuedHandler@call","maxTries":null,"maxExceptions":null,"failOnTimeout":false,"backoff":null,"timeout":null,"retryUntil":null,"data":{"commandName":"Illuminate\Broadcasting\BroadcastEvent","command":"O:38:"Illuminate\Broadcasting\BroadcastEvent":14:{s:5:"event";O:60:"Illuminate\Notifications\Events\BroadcastNotificationCreated":3:{s:10:"notifiable";O:45:"Illuminate\Contracts\Database\ModelIdentifier":5:{s:5:"class";s:15:"App\Models\User";s:2:"id";i:1;s:9:"relations";a:0:{}s:10:"connection";s:5:"mysql";s:15:"collectionClass";N;}s:12:"notification";O:44:"Filament\Notifications\BroadcastNotification":2:{s:4:"data";a:12:{s:2:"id";s:36:"9acab792-1d8a-48be-a2c1-226b84bf4c69";s:7:"actions";a:0:{}s:4:"body";N;s:5:"color";N;s:8:"duration";i:6000;s:4:"icon";N;s:9:"iconColor";N;s:6:"status";N;s:5:"title";s:18:"Saved successfully";s:4:"view";s:36:"filament-notifications::notification";s:8:"viewData";a:0:{}s:6:"format";s:8:"filament";}s:2:"id";s:36:"f624fe5e-b005-42c4-8469-cd4b36f370f0";}s:4:"data";a:12:{s:2:"id";s:36:"9acab792-1d8a-48be-a2c1-226b84bf4c69";s:7:"actions";a:0:{}s:4:"body";N;s:5:"color";N;s:8:"duration";i:6000;s:4:"icon";N;s:9:"iconColor";N;s:6:"status";N;s:5:"title";s:18:"Saved successfully";s:4:"view";s:36:"filament-notifications::notification";s:8:"viewData";a:0:{}s:6:"format";s:8:"filament";}}s:5:"tries";N;s:7:"timeout";N;s:7:"backoff";N;s:13:"maxExceptions";N;s:10:"connection";N;s:5:"queue";N;s:15:"chainConnection";N;s:10:"chainQueue";N;s:19:"chainCatchCallbacks";N;s:5:"delay";N;s:11:"afterCommit";N;s:10:"middleware";a:0:{}s:7:"chained";a:0:{}}"},"id":"XWjVjIXVrlz2gQbmqXUVCvV29qWCldVQ","attempts":0}
Jon Mason
Jon Mason8mo ago
i took it out of the job and just put it in the render method of my page to see if i could just get it to trigger. I see the broadcast/auth call and it's successful, but I don't see any request in the network tab that looks like a notification
Quin.
Quin.8mo ago
PusherBroadcaster.php:169 what is that line in your file maybe it is just a setup/config error i worked for a little time with pusher, it is a pain in the ass
Jon Mason
Jon Mason8mo ago
yeah it was a PITA when I worked with it before on my last project and it's proving to be difficult again this time around. Is there an easier alternative? I'm not tied to pusher at all..
MyFrend
MyFrend8mo ago
socketio need to run on a seperate node server thats the only downside U get actual bidirectional communication and that is not quite possible with pusher.
Jon Mason
Jon Mason8mo ago
Decided to stick with pusher and have been working through this issue. I'm at least getting a different error now: Pusher error: cURL error 7: Failed to connect to localhost port 6001 after 0 ms: Connection refused
Solution
Jon Mason
Jon Mason8mo ago
Was able to fix this by commenting out some of the variables in the broadcasting config built into laravel. Doesn't make sense, but it's working. i'll take the win and move on.
No description