Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaling with redis gives wrong presence user list #273

Open
WillRy opened this issue Nov 17, 2024 · 2 comments
Open

Scaling with redis gives wrong presence user list #273

WillRy opened this issue Nov 17, 2024 · 2 comments
Assignees

Comments

@WillRy
Copy link

WillRy commented Nov 17, 2024

Reverb Version

^1.0

Laravel Version

^11.9

PHP Version

8.3

Description

When using the "scaling" mode of "reverb" using "redis", when creating a "loadbalancer" to distribute the load between several servers, the list of active users in the channels does not work correctly.

If the user is being served by server A, he will only be able to see the presence of users connected to this server, he will not be able to see the presence of users in the same channel, but connected to server B.

Example:
In this example below, the "here" method will only return active connections on the same server that the user is connected to. It is impossible to see all online users across the cluster. I believe that it is necessary for Laravel to adopt an active session control through redis, as suggested by socket.io:

https://github.com/socketio/socket.io/blob/main/examples/private-messaging/server/sessionStore.js#L30

Echo.join('online')
            .here((users) => {
                console.log('here', users);

           
               
            })
            .joining((user) => {
                console.log('joining', user);

              
            })
            .leaving((user) => {
                console.log('leaving', user);

              
            })
            .error((error) => {
                console.error('error', error);
            });

Steps To Reproduce

To reproduce:

  • Enable "scaling" mode
  • Configure Redis in .env
  • Configure 2 instances of Reverb running
  • Apply a load balancer to connect to these two instances
  • Connect the user to a channel and you will see the problem

In "here" method you will see the problem

Echo.join('online')
            .here((users) => {
                console.log('here', users);

           

            })
            .joining((user) => {
                console.log('joining', user);

              
            })
            .leaving((user) => {
                console.log('leaving', user);

              
            })
            .error((error) => {
                console.error('error', error);
            });
@joedixon joedixon self-assigned this Nov 22, 2024
@dukmarques
Copy link

I'm having the same issue with scaling enabled and more than one server

@basdevet
Copy link

Same issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants