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

How to connect? #45

Open
salvinoto opened this issue Sep 2, 2023 · 1 comment
Open

How to connect? #45

salvinoto opened this issue Sep 2, 2023 · 1 comment

Comments

@salvinoto
Copy link

Do I use the same port as my FastAPI server? I have it running on port 8000, this is what my URL looks like when I try to connect

http://localhost:8000/ws/socket.io/

Is that correct, Im using the default setting.

Thanks

@leongkui
Copy link

This is a python client example:

import asyncio
import socketio

debug=False
sio = socketio.AsyncSimpleClient(
    logger=debug,
    engineio_logger=debug,
)

async def main():
    await sio.connect(
        'http://localhost:8000',
        socketio_path='/ws/socket.io',
        )
    await sio.emit('join', {'room': 'aaaa'})
    event = await sio.receive()
    print('event = {}'.format(event))
    await sio.emit('leave', {'room': 'aaaa'})
    event = await sio.receive()
    print('event = {}'.format(event))
    await sio.disconnect()

if __name__ == '__main__':
    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

2 participants