Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when close sockets - cannot found .fail_connection() #1478

Closed
Alfavisioner opened this issue Nov 20, 2024 · 8 comments
Closed

Error when close sockets - cannot found .fail_connection() #1478

Alfavisioner opened this issue Nov 20, 2024 · 8 comments
Assignees
Labels

Comments

@Alfavisioner
Copy link

Describe the bug
When try to close klines socket connection, exception is raised
AttributeError: 'ClientConnection' object has no attribute 'fail_connection'

To Reproduce
self.wsm is BinanceWebSocketManager

Stop working socket:
self.wsm.stop_socket(running_socket)

And
AttributeError: 'ClientConnection' object has no attribute 'fail_connection' is raised

from ReconnectingWebsocket:

    async def __aexit__(self, exc_type, exc_val, exc_tb):
        if self._exit_coro:
            await self._exit_coro(self._path)
        self.ws_state = WSListenerState.EXITING
        if self.ws:
            self.ws.fail_connection()

because self.ws is ClientConnection and does not have method fail_connection()
Only WebSocketCommonProtocol has that method

Expected behavior
Close socket

Environment (please complete the following information):

  • Python version: 3.13
  • OS: [Windows 10, also ubuntu]
  • python-binance version 1.0.22

Logs or Additional context
(aiohttp: 3.9.5)

@carlosmiei
Copy link
Collaborator

Hello @Alfavisioner,

Thanks for reporting, today we will release a new version that fixes this issue.

@carlosmiei carlosmiei self-assigned this Nov 20, 2024
@carlosmiei carlosmiei added the bug label Nov 20, 2024
@Alfavisioner
Copy link
Author

Thank you!

@yitech
Copy link

yitech commented Nov 23, 2024

Downgrade websockets can walkaround this:

pip uninstall websockets
pip install websockets==13.0

@carlosmiei
Copy link
Collaborator

@yitech Correct but shortly we will release a version that works with every websockets version.

@carlosmiei
Copy link
Collaborator

@yitech @Alfavisioner We just released a new version with the fix, can you please upgrade your python-binance and try again?

@Alfavisioner
Copy link
Author

s.fail_connection(

Yes, the latest version of the Python-Binance library works successfully.
When a socket is canceled, the message 'CANCEL read_loop' is shown without any errors.

However, I am experiencing other issues when using the latest version of CCXT (4.4.34) instead:

CCXT, in combination with Aiohttp 3.11.8, cannot start a socket for Binance.
CCXT, in combination with Aiohttp 3.10.8, cannot start the socket on the first attempt but succeeds on the second attempt.
CCXT, in combination with Aiohttp 3.9.5, works well.

@carlosmiei
Copy link
Collaborator

@Alfavisioner

When a socket is canceled, the message 'CANCEL read_loop' is shown without any errors.

I think this is just a warning but we will check it

However, I am experiencing other issues when using the latest version of CCXT (4.4.34) instead:

@Alfavisioner Can you please open an issue there?

@Alfavisioner
Copy link
Author

CANCEL read_loop

Yes, it is logging in the code:

    if self._handle_read_loop:
        self._log.error("CANCEL read_loop")
        await self._kill_read_loop()

Can you please open an issue there?
Yes, will open in CCXT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants