Comments (15)
Aaahhh...got it! Man, that seems so obvious now on a secon read through but totally missed the significance/implications of the namespacing when using the debug tool. Once I prefixed the event name with a ' . ' it started working like a charm. (so for anyone using the pusher test example in the debug tool your echo listener should look like:
window.Echo.listen('test_channel', '.my_event', (e) => {
console.log(e.name);
console.log(e.message);
});
Thanks for the response on this one @tlaverdure - you've saved me a ton of time next week!
from echo.
While using pusher's debug tool your namespace will be off unless you change it from the default Laravel setup. See here for how to configure: https://laravel.com/docs/5.3/broadcasting#namespaces
from echo.
I'm having the exact same problem. First I went through the docs and got my events talking to pusher just fine but my client side code doesn't trigger any callback on the listen method.
To be on the safe side I did a bare bones example following along with Matt Stauffers blogs post:
https://mattstauffer.co/blog/introducing-laravel-echo
Same outcome though. Works just fine for sending the event to pusher but the JS echo aspect just doesn't fire the callback.
I switched out laravel echo for the regular pusher library and code and the event is picked up in the browser just fine so I think it's probably an echo issue rather than anything to do with pusher per se.
import Echo from "laravel-echo"
// Init Echo
window.Echo = new Echo({
broadcaster: 'pusher',
key : 'pusher-key-redacted',
encrypted: true,
cluster: 'mt1'
});
window.Echo.channel('chat-room.1')
.listen('ChatMessageWasReceived', (e) => {
console.log('here');
console.log(e.test);
});
For reference the 'test' in the listen callback is the public property on my event class
from echo.
Just as a further update, I've just created a bare-bones test in a new laravel install and I've hit the same wall. Events get pushed to pusher just fine and/or if I create a test event in pusher I can see that my app subscribes in the pusher debug console but the callback just doesn't fire.
from echo.
@cedricve - I'm guessing you're not getting any other error messages in the console either right?
What sort of app are you building? Mine's a single page application built using vue js, vue router and vuex. Not sure that should make any difference but figured it was worth seeing if there are any similarities/differences in our use cases
from echo.
Well, it's just a proof-of-concept the code is in the bootstrap.js file, as recommended by the documentation. I was really hoping to get this work.. I think I'll move to the official library as wel. Thanks for the help
from echo.
Yeah, bit frustrating as Echo has some features that look pretty neat so I'd like to get it working if possible. If anyone else has any ideas or is having the same issue then I'd be happy to provide more info on my own usage
from echo.
I just use the pusher-js library directly. I just need to fetch the events and run my own functions.
Why should you use Laravel-echo?
from echo.
It has a ton of conveniences that basically I'd rather not have to write from scratch. I realise I can do everything with the pusher-js library I'd just rather get Echo working than reinvent the wheel...
from echo.
Well it looks like we will need to wait a little bit longer.. @taylorotwell
from echo.
@fourstacks Can you post your event code please...
from echo.
I posted a similar problem on SO just before finding this issue. Anyway, it did not work for me even with the namespace (\App\Events\...
, don't know why). So I had to name my events, then use a dot on front side.
from echo.
@fourstacks thank you man
from echo.
Aaahhh...got it! Man, that seems so obvious now on a secon read through but totally missed the significance/implications of the namespacing when using the debug tool. Once I prefixed the event name with a ' . ' it started working like a charm. (so for anyone using the pusher test example in the debug tool your echo listener should look like:
window.Echo.listen('test_channel', '.my_event', (e) => { console.log(e.name); console.log(e.message); });
Thanks for the response on this one @tlaverdure - you've saved me a ton of time next week!
from echo.
ohhh mean you saved me
from echo.
Related Issues (20)
- #listenToAll for NullConnector HOT 1
- #encryptedPrivate does not work with NullConnector HOT 1
- PresenceChannel interface missing 'Whisper' method HOT 2
- Implement `.listenOnce` and `.isListening` HOT 1
- [Bug] PresenceChannel interface missing 'Whisper' method HOT 2
- Nuxtjs + VUE 2 to update vue 3 + vite not working echo HOT 2
- Always got pusher ouput while using socket.io HOT 1
- Not subscribing to Echo when you open SPA as PWA from Homescreen HOT 4
- All the names of the events must be prefixed with a dot HOT 1
- Uncaught TypeError: event is undefined HOT 2
- Connection fails in Chrome, works just fine in FF HOT 1
- Export connectors and channels alongside with Echo and abstract classes HOT 2
- Laravel Echo with Socket.io HOT 1
- Centrifugo Connector HOT 1
- Fatal error when using channel.listen HOT 3
- Leave channel and disconnect right after HOT 1
- listen method does not work HOT 1
- Dont can get the returns of websocket
- dont cant get returns in console.log of the websocket, HOT 2
- ReferenceError: Property 'Pusher' doesn't exist HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from echo.