Install & Compatibility
Where this runs
tested against v0.0.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.378s · 33.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.0s · import 1.262s · 34MB
32MB installed
● package 32MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SocketManager
✓ from fastapi_socketio import SocketManager
Basic setup with FastAPI and SocketManager handling connect, disconnect, and message events.
from fastapi import FastAPI
from fastapi_socketio import SocketManager
app = FastAPI()
socket_manager = SocketManager(app=app)
@app.get("/")
def read_root():
return {"Hello": "World"}
@socket_manager.on('connect')
async def handle_connect(sid, environ):
print(f"Client connected: {sid}")
@socket_manager.on('disconnect')
async def handle_disconnect(sid):
print(f"Client disconnected: {sid}")
@socket_manager.on('message')
async def handle_message(sid, data):
await socket_manager.emit('response', {'data': 'Received'}, room=sid)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
Errors
Common errors & fixes
ImportError: cannot import name 'SocketManager' from 'fastapi_socketio'
Incorrect import path; used old pattern or installed wrong package.
fixUse: from fastapi_socketio import SocketManager
RuntimeError: You cannot use SocketManager without an app
SocketManager initialized without passing the FastAPI app object.
fixPass the app: SocketManager(app=app)
TypeError: __init__() got an unexpected keyword argument 'cors_allowed_origins'
CORS configuration is not passed to SocketManager directly; it must be set at the ASGI level.
fixUse SocketManager(app=app, cors_allowed_origins=[]) is invalid. Instead configure CORS via FastAPI middleware.
Upgrade
Version history
0.0.10latest on PyPI · released Mar 3, 2023
Audit
Dependencies
python-socketiorequiredCore dependency for Socket.IO functionality
fastapirequiredRequired for FastAPI app integration