This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
this is not even working at all #22
Comments
check your ports, are you using docker? |
you have typo in path string, change path: 'ws/socket.io' |
Setting path to I would really appreciate a little more documentation on how to connect to the server! |
Whoever ends up here and is trying within a python client, you can establish a connection with:
|
I ended up using socketio itself; MySocketManager.py class MySocketManager:
def __init__(self, app: FastAPI) -> None:
self._mgr = socketio.AsyncRedisManager(REDIS_TLS_URL)
self._sio: AsyncServer = socketio.AsyncServer(
client_manager=self._mgr,
async_mode=ASYNC_MODE,
cors_allowed_origins=[]
)
self._app = socketio.ASGIApp(
socketio_server=self._sio,
socketio_path=SOCKETIO_PATH
)
app.mount(MOUNT_LOCATION, self._app)
app.sio = self._sio
logging.info
def get_socket_manager(self) -> AsyncServer:
return self._sio app.py from MySocketManager import MySocketManager as SocketManager
app = FastAPI()
socketio_manager = SocketManager(app)
sm: AsyncServer = socketio_manager.get_socket_manager()
connected_users = set()
@sm.on('connect')
async def on_connect(sid, *args, **kwargs):
print('a user connected ', sid)
@sm.on('disconnect')
async def on_disconnect(sid, *args, **kwargs):
sm.leave_room(sid, room='orderaio')
ss = await sm.get_session(sid)
connected_users.remove(ss['username'])
print('a user disconnected ', sid) and make sure when you establish a connection from client use "/ws/socket.io/" as your path. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
main.py
CLIENT SIDE
The text was updated successfully, but these errors were encountered: