Error in ws_threaded.py

ansumanm
Hi,

I am getting these error messages in ws_threaded.py file:-

2018-07-03 14:44:27+0530 [-] Stopping factory
2018-07-03 14:44:30+0530 [-] Starting factory
2018-07-03 14:44:34+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 3 seconds
2018-07-03 14:44:34+0530 [-] Stopping factory
2018-07-03 14:44:37+0530 [-] Starting factory
2018-07-03 14:44:41+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 2 seconds
2018-07-03 14:44:41+0530 [-] Stopping factory
2018-07-03 14:44:44+0530 [-] Starting factory
2018-07-03 14:44:48+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 2 seconds
2018-07-03 14:44:48+0530 [-] Stopping factory
2018-07-03 14:44:51+0530 [-] Starting factory
2018-07-03 14:44:55+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 3 seconds
2018-07-03 14:44:55+0530 [-] Stopping factory
2018-07-03 14:44:59+0530 [-] Starting factory
2018-07-03 14:45:02+0530 [KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 3 seconds
2018-07-03 14:45:02+0530 [-] Stopping factory
2018-07-03 14:45:06+0530 [-] Starting factory

Anyone facing these issues ?


Thanks,
Ansuman
  • rakeshr
    @ansumanm
    Are you doing something in on_tick callback? Can you paste your ws_threaded.py code here.
  • ansumanm
    My on_tick callback code:-

    # Callback for tick reception.
    def on_ticks(ws, ticks):
    global ws_ctx
    tsb_dict = ws_ctx['tsb_dict']
    tsp = round(time.time() * 1000)
    tsb_dict = ws_ctx['tsb_dict']

    if len(ticks) > 0:
    #logging.debug("Ticks: {}".format(ticks))
    for inst in ticks:
    inst['tsp'] = tsp#inst['timestamp']
    inst['tradingsymbol'] = tsb_dict[inst['instrument_token']]
    publisher.sock_send(tsb_dict[inst['instrument_token']],
    json.dumps(inst, default=datetime_handler))

    Please let me know if you need the full code.
  • ansumanm
    # Callback when current connection is closed.
    def on_close(ws, code, reason):
    logging.info("Connection closed: {code} - {reason}".format(code=code, reason=reason))


    # Callback when connection closed with error.
    def on_error(ws, code, reason):
    logging.info("Connection error: {code} - {reason}".format(code=code, reason=reason))


    Nothing much going on there..
  • rakeshr
    @ansumanm , i'm asking where all you are calling on_close method?
  • ansumanm
    Hi Rakesh,

    We are not calling on_close() anywhere.
    We only register it.

    (env3) [ansuman@kuber]~/env3_projects/Infinity/ticks_collection$
    >grep on_close ws_threaded.py
    def on_close(ws, code, reason):
    kws.on_close = on_close
    (env3) [ansuman@kuber]~/env3_projects/Infinity/ticks_collection$
    >

    I am observing this on two different VMs so I am ruling out any environment issues.

    Thanks,
    Ansuman
  • ansumanm
    My kiteconnect version:-

    >pip3 show kiteconnect
    Name: kiteconnect
    Version: 3.7.0b1
    Summary: The official Python client for the Kite Connect trading API
    Home-page: https://kite.trade
    Author: Zerodha Technology Pvt ltd. (India)
    Author-email: [email protected]
    License: MIT
    Location: /home/ansuman/env3/lib/python3.6/site-packages
    Requires: requests, six, autobahn, Twisted, pyOpenSSL, service-identity, enum34, python-dateutil
    >

    Is this the latest one?
  • ansumanm
    I updated the kiteconnect to latest. Will run and see If I am hitting the issue. BTW, Is there any example where I reset the connection on the fly?

    >pip3 show kiteconnect
    Name: kiteconnect
    Version: 3.7.4
    Summary: The official Python client for the Kite Connect trading API
    Home-page: https://kite.trade
    Author: Zerodha Technology Pvt ltd. (India)
    Author-email: [email protected]
    License: MIT
    Location: /home/ansuman/env_infinity/lib/python3.6/site-packages/kiteconnect-3.7.4-py3.6.egg
    Requires: requests, six, pyOpenSSL, enum34, python-dateutil, autobahn

    >
  • zartimus
    @ansumanm Can you paste the full code?
    There should be some bug in the code. Can you enable debug flag and check for stacktraces ? Any exception occurring in the event loop will result in on_error which will in turn close the connection.
Sign In or Register to comment.