Registry / http-networking / fastapi-socketio

fastapi-socketio

JSON →
library0.0.10pypypi✓ verified 89d ago

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.

pip install fastapi-socketio
INSTALL
IMPORT
SIG · FASTAPI-SOCKETIO
F
fastapi-socketio
http-networkingpythonv0.0.10
Install
4.0s avg
Import
1320ms
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
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
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.378s · 33.9MB
glibc
py 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)
Debug
Known issues
gotchaSocketManager is not an ASGI application itself; the library does not support multiple socket.io endpoints out of the box.
fix
Use one SocketManager per app. For multiple endpoints, consider custom handling.
affects: all
gotchaThe `async_mode` argument defaults to 'asgi'. Setting it to 'sanic' or 'aiohttp' may break ASGI compatibility.
fix
Leave `async_mode` unset or set to 'asgi' for typical FastAPI usage.
affects: 0.0.8+
deprecatedThe library is no longer actively maintained; last release in 2022. May have compatibility issues with newer FastAPI or python-socketio versions.
fix
Consider using python-socketio's built-in ASGIApp directly (see python-socketio docs).
affects: >=0.0.10
Errors
Common errors & fixes
ImportError: cannot import name 'SocketManager' from 'fastapi_socketio'
Incorrect import path; used old pattern or installed wrong package.
fix
Use: from fastapi_socketio import SocketManager
RuntimeError: You cannot use SocketManager without an app
SocketManager initialized without passing the FastAPI app object.
fix
Pass 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.
fix
Use 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
Agent activity
6 hits · last 30 days
node
6
Resources
fastapi-socketio — pip install fastapi-socketio · libregistry