fastapi-socketio
fastapi-socketio copied to clipboard
provide an example script to connect by a python socketio.Client instance or from javascript
I have an issue connecting to the fastapi-socketio server by a python script. I am running this code:
import socketio
sio = socketio.Client()
sio.connect('http://0.0.0.0:8000')
I also tried with asyncio and i get another error:
import socketio
import asyncio
sio = socketio.AsyncClient()
async def main():
await sio.connect('http://0.0.0.0:8000')
asyncio.run(main())
pip install python-socketio[asyncio_client]
This worked for me.
import asyncio
sio = socketio.AsyncClient()
async def main():
await sio.connect('ws://localhost:8000', socketio_path='/ws/socket.io')
asyncio.run(main())