Connecting to Laravel echo presence channel problem

Published

I have a problem with connecting to presence channel, It is authenticated successfully and it is fired to the client but the event details are missed.
The problem message is: Unable to join channel. Member data for presence channel missing

Laravel console:

L A R A V E L  E C H O  S E R V E R

version 1.6.2

⚠ Starting server in DEV mode...

✔  Running at localhost on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!


- OWCJjy4o64iDbqMOAAAA joined channel: public_channel
- Preparing authentication request to: http://localhost/app/public/index.php/api/v1
- Sending auth request to: http://localhost/app/public/index.php/api/v1/broadcasting/auth


- Preparing authentication request to: http://localhost/app/public/index.php/api/v1
- Sending auth request to: http://localhost/app/public/index.php/api/v1/broadcasting/auth

- OWCJjy4o64iDbqMOAAAA authenticated for: private-private-channel
- OWCJjy4o64iDbqMOAAAA joined channel: private-private-channel
- OWCJjy4o64iDbqMOAAAA authenticated for: presence-presence-channel.1
******************************************
- Unable to join channel. Member data for presence channel missing 
******************************************
- OWCJjy4o64iDbqMOAAAA joined channel: presence-presence-channel.1

Laravel channels.php:

Broadcast::channel('private-channel.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

Broadcast::channel('presence-channel.{id}', function ($user, $id) {
    return ['id'=>$id,'user'=>$user->name];
});

Laravel BroadcastServiceProvider:

public function boot()
    {
        Broadcast::routes(['middleware' => ['auth:sanctum']]);
        require base_path('routes/channels.php');
    }

Clientcode:

echo!.join('presence-channel.1').here((users) {
      logger.e(jsonEncode(users));
    }).joining((user) {
      logger.e(jsonEncode(user));
    }).leaving((user) {
      logger.e(jsonEncode(user));
    }).listen('presence-channel PresenceEvent: ', (e) {
      logger.e(e);
    });

I have tried most solutions but with no luck, any suggestions?

Source: Laravel

Published
Categorised as laravel, laravel-echo, socket.io Tagged , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq