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

Web socket stream hangs when disconnected from the network midway #227

Open
Riyum opened this issue Apr 11, 2023 · 1 comment
Open

Web socket stream hangs when disconnected from the network midway #227

Riyum opened this issue Apr 11, 2023 · 1 comment
Labels
reviewing reviewing the issue

Comments

@Riyum
Copy link
Contributor

Riyum commented Apr 11, 2023

Issue subject

The Program hangs when disconnected from the network midway.

Expected behaviour

The on_error handler should throw a connection error exception.

Actual behaviour

The Program hangs after disconnecting, on reconnect there is a delay (which seems like the actual time where the machine was without a connection) which produces an output of (old ?) data.

note: if the connection isn't back, the program is stuck util killed with ctrl+c

Steps to reproduce

Go offline when it starts printing data to the screen

#!/usr/bin/env python

import time
import logging
from binance.lib.utils import config_logging
from binance.websocket.spot.websocket_stream import SpotWebsocketStreamClient

config_logging(logging, logging.DEBUG)


def message_handler(_, message):
    logging.info(message)


my_client = SpotWebsocketStreamClient(on_message=message_handler)


my_client.mini_ticker()

time.sleep(10)

logging.debug("closing ws connection")
my_client.stop()

Environment

  • Version of binance-connector-python: 3.0.0rc1
  • Python version: 3.7.12
  • Operating system Linux
@2pd 2pd added the reviewing reviewing the issue label Apr 17, 2023
@MattGreeny
Copy link

@2pd - I can see that this pull-request #228 was merged into the branch rc-3.5.0, but was then followed by c788d3a, which seemed to remove this on_websocket_error, so the issue still seems to stand.

How would you recommend we go about reconnecting and resubscribing ourselves in the event of a WebSocketTimeoutException?

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

No branches or pull requests

3 participants