Skip to content

1001 Going Away does not trigger on_close function #63

@jchappe

Description

@jchappe

Receiving a Close 1001 message from websocket is not triggering the on_close function and the associated retry logic.

Here is my connection snippet:

`

def start_websocket(self):
    while True:
        client = WSClient(api_key=self.api_key, api_secret=self.signing_key, on_message=self.on_message, on_open=self.on_open, on_close=self.on_close, verbose=True, timeout=5)
        try:
            client.open()
            client.subscribe(product_ids=[], channels=["user"])
            client.run_forever_with_exception_check()
        except WSClientConnectionClosedException as e:
            logging.info(f"User Orders Websocket Connection closed! Retry attempts exhausted. {e}")
        except WSClientException as e:
            logging.info(f"User Orders Websocket Error encountered!. {e}")
        time.sleep(.2)`

And here is the logging:

2024-08-06 22:53:08 - websockets.client - DEBUG - % sending keepalive ping
2024-08-06 22:53:08 - websockets.client - DEBUG - > PING 8d 71 87 e4 [binary, 4 bytes]
2024-08-06 22:53:08 - websockets.client - DEBUG - < CLOSE 1001 (going away) [2 bytes]
2024-08-06 22:53:08 - websockets.client - DEBUG - = connection is CLOSING
2024-08-06 22:53:08 - websockets.client - DEBUG - > CLOSE 1001 (going away) [2 bytes]
2024-08-06 22:53:08 - websockets.client - DEBUG - = connection is CLOSED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions