Web sockets - pusher replacement - doesn't work
-
#pusher
#laravel_echo -
@Ashrakat-Mokhtar
could you please provide more detail about your query! -
@Vaishali-Agarwal
Now I'm using web-sockets - pusher replacement in laravel - I have followed this steps https://beyondco.de/docs/laravel-websockets/basic-usage/pusher
But yet it tells me that Echo is not defined, However I have written its configuration in resources/assets/js/bootstrap.js
It seems it doesn't read from this file.
Here's code written:import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
encrypted: true,
wsHost: window.location.hostname,
wsPort: 6001
}); -
Any help??
It's mandatory. -
I think compilation is missing did you compiled your code properly. Because I did not see anything wrong with your code.
-
@devansh-webkul I did, I ran 'npm run dev', 'npm run watch', still the same problem.
somehow it's not reading from that file 'resources/assets/js/bootstrap.js'. -
Just check if echo dependencies are installed or not this seems to be a configuration issue.
-
@devansh-webkul I have "laravel-echo" => "^1.10.0" & "pusher-js" => "^7.0.3" in my package.json file,
"pusher/pusher-php-server" => "^5.0" & "beyondcode/laravel-websockets" => "^1.12" in composer.json file.Is there anything else missing??
-
Your error clearly signifies that the echo is not defined. That means echo is not importing if something is not importing then either dependency issue or path issue.
-
@devansh-webkul Now error is resolved and read properly, however it's not listening correctly in front-end, backend is working fine. but in html page no rendering is happening when action is taking. it doesn't listen to the event fired in backend.