socketIO-client-2
socketIO-client-2 copied to clipboard
Running socket.io server and socket.io client in the same app
I want to run both socket.io server and socket.io client on the same port of my localhost.
Server without client works (I use flask socket io)
from flask_socketio import send, emit, SocketIO
app = Flask(__name__)
socketio = SocketIO(app)
if __name__ == '__main__':
socketio.run(app)
Client separately works as well
from socketIO_client import SocketIO as client_socketio, BaseNamespace
my_client = client_socketio('localhost', 5001, Namespace)
def on_aaa_response(*args):
print('on_aaa_response', args)
my_client.on('aaa_response', on_aaa_response)
my_client.wait()
But they are mutually blocking if I start the server first - the client does not start. If I start the client first - the server will not start. Do you maybe have an idea how to start both?