connect(sid, environ) function doesm't work

34 Views Asked by At

i am trying to make a server client connection for deep learning the client is a self driving car simulator with the same port number and the server is the code i implemented as follows :

import socketio
import eventlet
from flask import Flask

sio = socketio.Server()

app = Flask(__name__)


@sio.on('connect')
def connect(sid, environ):
    print('Connected')


if __name__ == '__main__':
    app = socketio.Middleware(sio, app)
    eventlet.wsgi.server(eventlet.listen(('', 4567)), app)

after i run the program, it should print the word Connected when i open the simulator but once i open it, it only shows that the connection is accepted like the following :

enter image description here how can i make the connect function to connect properly ? i am using pycharm

i tried making a client code but same thing happens i tried to use some code from the library to test but again, it gave the same response, here is the code i tried:

import eventlet
import socketio


sio = socketio.Server()
app = socketio.WSGIApp(sio, static_files={
    '/': {'content_type': 'text/html', 'filename': 'index.html'}
})

@sio.event
def connect(sid, environ):
    print('connect ', sid)

@sio.event
def my_message(sid, data):
    print('message ', data)

@sio.event
def disconnect(sid):
    print('disconnect ', sid)

if __name__ == '__main__':
    eventlet.wsgi.server(eventlet.listen(('', 4567)), app)
0

There are 0 best solutions below