Describe the bug
Whenever multiple clients try to send a message to the server simultaneously, the server only emits once to one of the clients and not to all clients. But it works when multiple clients come one after one and make a join call. The below is the sample code -
This is how I have configured socket.io with aiohttp.
Server Setup
if __name__ == '__main__':
sio = socketio.AsyncServer(async_mode='aiohttp', cors_allowed_origins='*')
sio.register_namespace(LiveCompetitionNamespace('/live_competition'))
app = web.Application()
sio.attach(app)
web.run_app(app, path=args.path)
This is how i have declared the namespace -
BaseNamespace.py
class BaseNamespace(socketio.AsyncNamespace):
async def on_connect(self, sid, environ):
log.info("Connected")
def on_disconnect(self, sid):
log.info("Disconnected")
CompetitionNamespace.py
class LiveCompetitionNamespace(BaseNamespace):
async def on_join(self, sid, msg):
log.info("Join called by the user")
room = 'competition_%s' % msg['competition_id']
log.info("Putting the user in the room.")
self.enter_room(sid, room)
data = {} // This is the data from mongodb call
log.info("Emitting the live_competition_joined to all users in the room except the new joiner")
await self.emit('live_competition_joined', {'data': data}, room=room, skip_sid=sid)
Now when multiple clients after making a connection to the server, send a join message, the server only responds to some clients and not all. The server should emit to all clients except one making the join call.
Describe the bug
Whenever multiple clients try to send a message to the server simultaneously, the server only emits once to one of the clients and not to all clients. But it works when multiple clients come one after one and make a join call. The below is the sample code -
This is how I have configured socket.io with aiohttp.
Server Setup
This is how i have declared the namespace -
BaseNamespace.py
CompetitionNamespace.py
Now when multiple clients after making a connection to the server, send a join message, the server only responds to some clients and not all. The server should emit to all clients except one making the join call.