Giter VIP home page Giter VIP logo

Comments (15)

fourstacks avatar fourstacks commented on July 20, 2024 41

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.

tlaverdure avatar tlaverdure commented on July 20, 2024 5

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.

fourstacks avatar fourstacks commented on July 20, 2024 2

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.

fourstacks avatar fourstacks commented on July 20, 2024 2

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.

fourstacks avatar fourstacks commented on July 20, 2024

@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.

cedricve avatar cedricve commented on July 20, 2024

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.

fourstacks avatar fourstacks commented on July 20, 2024

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.

cedricve avatar cedricve commented on July 20, 2024

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.

fourstacks avatar fourstacks commented on July 20, 2024

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.

cedricve avatar cedricve commented on July 20, 2024

Well it looks like we will need to wait a little bit longer.. @taylorotwell

from echo.

Chathula avatar Chathula commented on July 20, 2024

@fourstacks Can you post your event code please...

from echo.

rap2hpoutre avatar rap2hpoutre commented on July 20, 2024

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.

abdullahessam avatar abdullahessam commented on July 20, 2024

@fourstacks thank you man

from echo.

midoDiv avatar midoDiv commented on July 20, 2024

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.

midoDiv avatar midoDiv commented on July 20, 2024

ohhh mean you saved me

from echo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.