pyropy / fastapi-socketio

Easily integrate socket.io with your FastAPI app 🚀
Apache License 2.0
328 stars 31 forks source link

How to set SocketManager server options? #42

Open MPuust opened 1 year ago

MPuust commented 1 year ago

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

kodzonko commented 12 months ago

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)