Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

provide an example script to connect by a python socketio.Client instance or from javascript #31

Open
ermal-abiti opened this issue Jul 28, 2022 · 2 comments

Comments

@ermal-abiti
Copy link

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())
@baozaodetudou
Copy link

pip install python-socketio[asyncio_client]

@Adam-D-Lewis
Copy link

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())

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants