Skip to content

Why laravel broadcast channel has a prefix? #229

@adhenrique

Description

@adhenrique

I've gone through the following steps:

  1. I created a new project with laravel 5.8;
  2. I have modified the values ​​of the BROADCAST_DRIVER and QUEUE_DRIVER entries in my .env to redis;
  3. I created a new channel route in the routes/channel.php file with the name test-asd;
  4. I created a new event with the name MessageSent;
  5. In the broadcastOn method I added: `return new Channel ('test-asd');
  6. I created a test route in the routes/web.php file with the name test, and added a callback: broadcast(new MessageSent ());
  7. I installed laravel-echo-server globally;
  8. I installed the depencences with npm install;
  9. I installed laravel-echo with npm install laravel-echo
  10. I installed predis/predis with composer require predis/predis
  11. I modified the resources /js/bootstrap.js file by importing socket.io-client and pointing socket.io as broadcaster;
  12. I've added a listener to the Echo in my TestComponent.vue: Echo.channel('test-asd').listen ('MessageSent', (e) => {};
  13. I started the redis-server, the laravel-echo-server, the artisan serve and the queue:listen;
  14. testing...

Okay, there were a lot of steps, but by taking the test I do not get any feedback from my listener. I noticed that in the laravel-echo-server console, it returns the channel as laravel_database_test-asd.

So I changed the listener channel in my component from channel ('test-asd') to channel ('laravel_database_test-asd') and it works normally.

So my question is: Why is laravel creating a channel with the prefix laravel_database_?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions