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

Support for Socket.IO v4.1.0 inter-server communication (serverSideEmit) #1436

Open
Kakadus opened this issue Mar 1, 2025 · 1 comment
Open
Assignees

Comments

@Kakadus
Copy link

Kakadus commented Mar 1, 2025

Is your feature request related to a problem? Please describe.
In a multi-server scenario with a message queue such as redis or rabittmq, it is important to be able to send messages between servers.
That is why socket.io 4.1 introduced the serverSideEmit function: dzad/socket.io@491a9a0. This seems to be missing from python-socketio though.

Ideally, parameters like room or to can limit the servers the message is sent to.

Describe the solution you'd like
A sio.server_side_emit(..., to=..., room=...) function and self.server_side_emit(..., to=..., room=...) method to do inter-server communication.

Describe alternatives you've considered

  • adding clients between servers manually. This is not really feasible with dynamically scaled servers.
  • configuring the client manager manually. This seems not feasible either.

Additional context

# server A
await sio.server_side_emit("hello", "world", room="test")


# server B
@sio.on("hello")
async def server_notifications(sid, message):
    print(message)  # should print "world" if server is in room "test"
@miguelgrinberg
Copy link
Owner

This is not a top priority for me at this time, but I would be open to add this if someone contributes it.

But, I do not quite follow some of your requests:

Ideally, parameters like room or to can limit the servers the message is sent to.

What does it mean to send a server side emit to a room? If there are clients in that room, do they get the message? How do you add a server to a room? What do you pass in the to argument to reference a specific server? I don't see what is the point of this, or what problem does it solve.

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

No branches or pull requests

2 participants