Python Forum
Impementing a client that connects to the server
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Impementing a client that connects to the server
#1
I have a cllient and webserver running but when connecting I receive a 404:not found error.
import socketio
sio = socketio.Client()
@sio.event
def connect():
    print (' connection established')
@sio.event
def disconnect():
    print(' disconnected from server')
sio.connect ('http://localhost:8080')
sio.emit('message', {'data':'my_data'})
sio.wait()
import socketio
from aiohttp import web
socket_io = socketio.AsyncServer()
app = web.Application()
socket_io.attach(app)

async def index(request):
    return web.Response(text='Hello world from socketio',content_type='text/html')
from aiohttp import web

@socket_io.on('message')
def print_message(socket_id, data):
    print("Socket ID:' , socket_id")
    print("Data : ", data)
    app.router.add_get('/', index)

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


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020