feus4177 / socketIO-client-2

A socket.io client library for Python
http://pypi.python.org/pypi/socketIO-client-2
MIT License
16 stars 15 forks source link

Running socket.io server and socket.io client in the same app #12

Open denysthegitmenace opened 7 years ago

denysthegitmenace commented 7 years ago

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?