Skip to content

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

Description

@denysondata

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions