mandrewcito / signalrcore

SignalR Core python client
https://mandrewcito.github.io/signalrcore/
MIT License
115 stars 53 forks source link

on_error function is not called #101

Open HishamKassar opened 1 year ago

HishamKassar commented 1 year ago

Describe the bug I was trying to get the error when something happened in a handshake or when the server is not reachable, but it seems the function is not working properly

here is my code:

To Reproduce hub_connection = HubConnectionBuilder()\ .with_url(hubUrl, options={ "access_token_factory": lambda: token, "skip_negotiation": True, "verify_ssl": False })\ .configure_logging(logging.DEBUG, socket_trace=False)\ .with_automatic_reconnect({ "type": "interval", "keep_alive_interval": 10, "intervals": [1, 3, 5, 6, 7, 87, 3]})\ .build()

    def on_connection_closed():
        print("connection closed")
        connection_closed = True
        print(connection_closed)

    def on_connection_error(data):
        print("An exception was thrown closed")
        print(data)
        callback(False)

    hub_connection.on_close(on_connection_closed)
    hub_connection.on_error(on_connection_error)  

    while True:
        if connection_closed:
            break

Expected behavior I'm getting all errors on debug level, but I want to get the error from the function on_error and this is not happening. so is there any issue with my previous code?