Websocket ticks stop after disconnection and reconnection

algonauts
Hi,
I am using pykiteconnect and had a problem with reconnection after the websocket disconnection.
The websocket connection with my app got disconnected with code 1006 and it was reconnected after 3 seconds. But I did not receive ticks after the reconnection. Pykiteconnect does resubscribe to the tokens I believe still I did not receive ticks. Do I have to resubscribe to the tokens for the ticks? Or there could be some another issue?
  • sujith
    @algonauts,
    Kite Ticker will return a cached tick after reconnection. Since a subscribe message is sent for all the tokens.
  • gauravmane
    Hi @sujith, we too are facing a similar issue for the past couple of days.
    Websocket reconnects but the process doesn't get any tick updates. It was working fine till now, a few disconnects and it always used to resume fine.
    But this week it just reconnects without any tick updates.

    FYI, I'm not resubscribing tokens in case of reconnection, and no changes have been made recently.
    Is there any particular case when we should resubscribe?
  • sujith
    @gauravmane,
    You don't have to subscribe again after disconnect. The Kite Connect library takes care of subscribing.
    Let me check if we can reproduce this.
  • rakeshr
    @gauravmane
    We tried re-producing, but re-connection is happening all fine.
    count: 2. Next retry in around: 8 seconds
    2020-07-08 17:31:56+0530 [-] <twisted.internet.tcp.Connector instance at 0x7fca42ac7c88 disconnected IPv4Address(type='TCP', host='ws.kite.trade', port=443)> will retry in 20 seconds
    2020-07-08 17:31:56+0530 [-] Stopping factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x7fca44f77668>
    2020-07-08 17:32:17+0530 [-] Starting factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x7fca44f77668>
    2020-07-08 17:32:17+0530 [-] {'tradable': True, 'mode': 'full',
    'instrument_token': 55757831,
    'last_price': 3060.0, 'last_quantity': 1,
    'average_price': 3042.85, 'volume': 34601,
    'buy_quantity': 4049, 'sell_quantity': 3352,
    'ohlc': {'open': 3040.0, 'high': 3063.0,
    'low': 3029.0, 'close': 3063.0}, ...}]}}
  • gauravmane
    gauravmane edited July 2020
    [pid 17798:tid 140226802480896] [Wed Jul 08 09:30:06.764] (17798:1402268
    02480896) ERROR ticker.py{_on_error:660}: Connection error: 1006 - connection was closed uncleanly (None)
    [pid 17798:tid 140226802480896] [Wed Jul 08 09:30:06.764] (17798:1402268
    02480896) ERROR ticker.py{_on_close:653}: Connection closed: 1006 - connection was closed uncleanly (None)
    [pid 17798:tid 140226802480896] [Wed Jul 08 09:30:06.764] (17798:140226802480896) ERROR kiteconnhandler.py{ws_on_close:301}: Lost Web socket connection 1006-connection was closed uncleanly (None), trying to reconnect
    [pid 17798:tid 140226802480896] [Wed Jul 08 09:30:09.515] (17798:140226802480896) INFO kiteconnhandler.py{ws_on_connect:296}: Web socket connection established successfully, response {"peer": "tcp4:13.127.38.177:443", "headers": {"date": "Wed, 08 Jul 2020 04:00:09 GMT", "connection": "upgrade", "upgrade": "websocket", "sec-websocket-accept": "/kK4DQdhRIcXHjPyzNFsOimJxQ4="}, "version": 18, "protocol": null, "extensions": []}

    These are my logs, it got disconnected at 9.30, go reconnected, but no ticks post this
    What'll other errors possible?
  • rakeshr
    @gauravmane
    {ws_on_connect:296}: Web socket connection established successfully
    If re-connection has happen successfully,token should be re-subscribed too. Can you paste your Websocket code? We will take look at it.
Sign In or Register to comment.