Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Websocket handling error and reconnection with TCP_NODELAY=1 #115

@kheil117

Description

@kheil117

Hi team,

When I open a websocket by providing a socket to function KucoinWsClient.create() in order to set TCP_NODELAY to 1 (see example /example_customized_ws_public.py), exceptions are not handled correctly.

When the current websocket connection raises a ConnectionClosedError and then tries to reconnect via _reconnect(), the reconnection fails over and over with error: 'An operation was attempted on something that is not a socket', see below.

Note that without providing a socket to KucoinWsClient.create() and therefore not disabling TCP_NODELAY, the reconnection works.

WARNING _reconnect(112) <Task finished name='Task-X' coro=<ConnectWebsocket._run() done, defined at path\site-packages\kucoin\websocket\websocket.py:34> exception=ConnectionClosedError(None, None, None)> got an exception no close frame received or sent
WARNING _reconnect(124) _reconnect over.
INFO _reconnect(92) Websocket start connect/reconnect
INFO _reconnect(96) asyncio sleep reconnect_wait=1 s reconnect_num=1
INFO _reconnect(98) asyncio sleep ok
INFO _recover_topic_req_msg(127) recover topic event ['/market/level2:HBAR-USDT'] waiting

WARNING _reconnect(112) <Task finished name='Task-XXX' coro=<ConnectWebsocket._run() done, defined at path\site-packages\kucoin\websocket\websocket.py:34> exception=OSError(10038, 'An operation was attempted on something that is not a socket', None, 10038, None)> got an exception [WinError 10038] An operation was attempted on something that is not a socket

WARNING _reconnect(114) pending <Task pending name='Task-XXX' coro=<ConnectWebsocket._recover_topic_req_msg() running at path\site-packages\kucoin\websocket\websocket.py:128> wait_for=<Future pending cb=[Task.__wakeup()]>>
WARNING _reconnect(119) cancel ok.
WARNING _reconnect(124) _reconnect over._

Metadata

Metadata

Assignees

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