fastapi-socketio icon indicating copy to clipboard operation
fastapi-socketio copied to clipboard

How to set SocketManager server options?

Open MPuust opened this issue 2 years ago • 1 comments
trafficstars

Where to set pingTimeout for server https://socket.io/docs/v4/server-options/#pingtimeout ?

MPuust avatar Mar 21 '23 12:03 MPuust

you need to pass them as kwargs to SocketManager's initializer. Kwargs are then forwarded to socketio.AsyncServer's initializer. Here's the implementation:

# SocketManager's initializer:
def __init__(
        self,
        ...
        **kwargs
    ) -> None:
        self._sio = socketio.AsyncServer(async_mode=async_mode, cors_allowed_origins=cors_allowed_origins, **kwargs)
        ...

And in AsyncServer you have all these params used both by Asyncserver and by EngineIO, among others ping_timeout (reference for parameters: https://python-socketio.readthedocs.io/en/latest/api.html#asyncserver-class)

kodzonko avatar Aug 24 '23 17:08 kodzonko