{"id":23713,"library":"fastapi-socketio","title":"FastAPI SocketIO","description":"A library to easily integrate Socket.IO with FastAPI applications. Current version is 0.0.10, last updated in 2022. Release cadence is low, with infrequent updates. It wraps the python-socketio library for ASGI mode.","status":"maintenance","version":"0.0.10","language":"python","source_language":"en","source_url":"https://github.com/pyropy/fastapi-socketio","tags":["fastapi","socket.io","websocket","async"],"install":[{"cmd":"pip install fastapi-socketio","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Core dependency for Socket.IO functionality","package":"python-socketio","optional":false},{"reason":"Required for FastAPI app integration","package":"fastapi","optional":false}],"imports":[{"note":"","wrong":null,"symbol":"SocketManager","correct":"from fastapi_socketio import SocketManager"}],"quickstart":{"code":"from fastapi import FastAPI\nfrom fastapi_socketio import SocketManager\n\napp = FastAPI()\nsocket_manager = SocketManager(app=app)\n\n@app.get(\"/\")\ndef read_root():\n    return {\"Hello\": \"World\"}\n\n@socket_manager.on('connect')\nasync def handle_connect(sid, environ):\n    print(f\"Client connected: {sid}\")\n\n@socket_manager.on('disconnect')\nasync def handle_disconnect(sid):\n    print(f\"Client disconnected: {sid}\")\n\n@socket_manager.on('message')\nasync def handle_message(sid, data):\n    await socket_manager.emit('response', {'data': 'Received'}, room=sid)\n\nif __name__ == \"__main__\":\n    import uvicorn\n    uvicorn.run(app, host=\"0.0.0.0\", port=8000)","lang":"python","description":"Basic setup with FastAPI and SocketManager handling connect, disconnect, and message events."},"warnings":[{"fix":"Use one SocketManager per app. For multiple endpoints, consider custom handling.","message":"SocketManager is not an ASGI application itself; the library does not support multiple socket.io endpoints out of the box.","severity":"gotcha","affected_versions":"all"},{"fix":"Leave `async_mode` unset or set to 'asgi' for typical FastAPI usage.","message":"The `async_mode` argument defaults to 'asgi'. Setting it to 'sanic' or 'aiohttp' may break ASGI compatibility.","severity":"gotcha","affected_versions":"0.0.8+"},{"fix":"Consider using python-socketio's built-in ASGIApp directly (see python-socketio docs).","message":"The library is no longer actively maintained; last release in 2022. May have compatibility issues with newer FastAPI or python-socketio versions.","severity":"deprecated","affected_versions":">=0.0.10"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from fastapi_socketio import SocketManager","cause":"Incorrect import path; used old pattern or installed wrong package.","error":"ImportError: cannot import name 'SocketManager' from 'fastapi_socketio'"},{"fix":"Pass the app: SocketManager(app=app)","cause":"SocketManager initialized without passing the FastAPI app object.","error":"RuntimeError: You cannot use SocketManager without an app"},{"fix":"Use SocketManager(app=app, cors_allowed_origins=[]) is invalid. Instead configure CORS via FastAPI middleware.","cause":"CORS configuration is not passed to SocketManager directly; it must be set at the ASGI level.","error":"TypeError: __init__() got an unexpected keyword argument 'cors_allowed_origins'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}