binance-connector-python icon indicating copy to clipboard operation
binance-connector-python copied to clipboard

Websocket connection was closed uncleanly

Open abhishekg2389 opened this issue 2 years ago • 1 comments

Issue subject

Websocket connection was closed uncleanly

Expected behaviour

There should not be any WARNING when the connection is getting closed. Also, I am not sure if there is any side-effects of closing the connection uncleanly.

Actual behaviour

While closing the connection with my_client.stop() following warning comes : 2022-09-21 07:52:41.697 UTC WARNING binance.websocket.binance_client_protocol: WebSocket connection closed: connection was closed uncleanly ("peer dropped the TCP connection without previous WebSocket closing handshake"), code: 1006, clean: False, reason: connection was closed uncleanly ("peer dropped the TCP connection without previous WebSocket closing handshake")

Steps to reproduce

import os, certifi
os.environ['SSL_CERT_FILE'] = certifi.where()

import time
import logging
from binance.lib.utils import config_logging
from binance.websocket.spot.websocket_client import SpotWebsocketClient as Client

config_logging(logging, logging.DEBUG)


def message_handler(message):
    print(message)


my_client = Client()
my_client.start()

my_client.kline(symbol="btcusdt", id=1, interval="1m", callback=message_handler)
time.sleep(5)

my_client.stop() # line which produces warning

Environment

Relevant information about setup:

  • Version of binance-connector-python - 1.17.0
  • Python version - Python 3.10.6 (main, Sep 15 2022, 15:59:34) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
  • Operating system - MacOS Darwin

abhishekg2389 avatar Sep 21 '22 08:09 abhishekg2389

Please check the v3 websocket which has the new design.

2pd avatar Feb 15 '23 00:02 2pd