Skip to content

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

Description

@Kakadus

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"

Activity

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

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions