It looks like you're new here. If you want to get involved, click one of these buttons!
ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (None)
ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (None)
I have my code as-
def on_ticks(ws, ticks):
    print(ticks)
    for tick in ticks:
        market_quotes = MarketQuotes.objects.create(instrument_token = tick.get('instrument_token'))
        market_quotes.tradable = tick.get('tradable')
        market_quotes.instrument_token = tick.get('instrument_token')
        market_quotes.last_price = tick.get('last_price')
        market_quotes.buy_quantity = tick.get('buy_quantity')
        market_quotes.sell_quantity = tick.get('sell_quantity')
        market_quotes.timestamp = tick.get('timestamp')
        market_quotes.save()
def on_connect(ws, response):
    # Callback on successful connect.
    # Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
    ins_token_list = [111,222,333,444]
    ws.subscribe(ins_token_list)
    ws.set_mode(ws.MODE_FULL,ins_token_list)
def on_close(ws, code, reason):
    # On connection close stop the main loop
    # Reconnection will not happen after executing `ws.stop()`
    ws.stop()
def subscription_for_instrument():
    # Assign the callbacks.
    api_key = 'lqcf'
    access_token = get_or_none(KiteToken, is_valid = True)
    kws = KiteTicker(api_key, access_token.access_token)
    kws.on_ticks = on_ticks
    kws.on_connect = on_connect
    kws.on_close = on_close
    # Infinite loop on the main thread. Nothing after this will run.
    # You have to use the pre-defined callbacks to manage subscriptions.
    kws.connect()
How to rectify it?                            
kws.connect(threaded=True)Getting same error after some time.