coinbase / coinbase/coinbase-advanced-py

1001 Going Away does not trigger on_close function

Open
#63 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
361
Forks
131
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at WSClient.open() and run_forever_with_exception_check(), then trace how a WebSocket close with code 1001 is dispatched to the on_close callback and retry handling. Reproduce the close sequence using the connection snippet and confirm that the callback and associated retry logic run before considering the issue done.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.