icicidirect breeze_connect websocket is closing instantly on startup

254 Views Asked by At

I am using the direct code snippet from icicidirect breeze_connect api documentation. It is instantly getting closed after subscription of data feed is successful. I am facing this issue in Pycharm and aws cloud9 IDE. The code is running fine and callback function returning the expected data in Jupyter notebook. The code I am using is as below,

from breeze_connect import BreezeConnect

from time import sleep

api_key = ""
api_secret = ""
session_token = ""

breeze = BreezeConnect(api_key=api_key)
breeze.generate_session(api_secret=api_secret, session_token=session_token)


# Connect to websocket(it will connect to tick-by-tick data server)
breeze.ws_connect()


def on_ticks(tick):
    print("Ticks: {}".format(tick))


# Assign the callbacks.
breeze.on_ticks = on_ticks
sleep(2)

breeze.subscribe_feeds(
    exchange_code="NFO",
    stock_code="CNXBAN",
    product_type="options",
    expiry_date="11-Oct-2023",
    strike_price="45000",
    right="Call",
    get_exchange_quotes=True,
    get_market_depth=False,
)

I tried to uninstall the breeze_connect api and reinstalled it but of no use. I have also checked other websocket libraries which are up to date. As I am using direct code from api documentation, nothing seems wrong in the code. api link https://pypi.org/project/breeze-connect/

0

There are 0 best solutions below