binance / binance-connector-python

Simple connector to Binance Public API
MIT License
1.92k stars 496 forks source link

Websocket connection was closed uncleanly #168

Open abhishekg2389 opened 2 years ago

abhishekg2389 commented 2 years ago

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:

2pd commented 1 year ago

Please check the v3 websocket which has the new design.