Python-socketio: 'socketio' has no attribute 'AsyncServer'

Created on 15 Jul 2018  路  1Comment  路  Source: miguelgrinberg/python-socketio

I'm trying to run the example script:

from aiohttp import web
import socketio

sio = socketio.AsyncServer()
app = web.Application()
sio.attach(app)

async def index(request):
    """Serve the client-side application."""
    with open('index.html') as f:
        return web.Response(text=f.read(), content_type='text/html')

@sio.on('connect', namespace='/chat')
def connect(sid, environ):
    print("connect ", sid)

@sio.on('chat message', namespace='/chat')
async def message(sid, data):
    print("message ", data)
    await sio.emit('reply', room=sid)

@sio.on('disconnect', namespace='/chat')
def disconnect(sid):
    print('disconnect ', sid)

app.router.add_static('/static', 'static')
app.router.add_get('/', index)

if __name__ == '__main__':
    web.run_app(app)

Which gives me the error:

Traceback (most recent call last):
  File "websockServer.py", line 4, in <module>
    sio = socketio.AsyncServer()
AttributeError: module 'socketio' has no attribute 'AsyncServer'

Most helpful comment

>All comments

Was this page helpful?
0 / 5 - 0 ratings