ERROR:kiteconnect.ticker:Retrying connection

deadlock
After kite.connect(), onconnect() and onticks() callbacks are not called since this morning. I am getting this error from market open.
"ERROR:kiteconnect.ticker:Retrying connection...". One thing that changed since Friday is that I have enabled TOTP authentication. I am able to successfully login though and receive access token. As mentioned before, kite.connect() call is successful but call backs are not called.

Terminal log:
RROR:kiteconnect.ticker:Retrying connection. Retry attempt count: 1. Next retry in around: 3 seconds
INFO:root:Reconnecting: 1
ERROR:kiteconnect.ticker:Retrying connection. Retry attempt count: 2. Next retry in around: 7 seconds
INFO:root:Reconnecting: 2
ERROR:kiteconnect.ticker:Retrying connection. Retry attempt count: 3. Next retry in around: 17 seconds
INFO:root:Reconnecting: 3

Code:
from kiteconnect import KiteTicker
import logging

def onconnect(ws, response):
ws.subscribe(tokens)
ws.set_mode(ws.MODE_FULL, tokens)

def onticks(ws, ticks):
logging.info("Ticks: {}".format(ticks))

def onclose(ws, code, reason):
logging.info("Connection closed: {code} - {reason}".format(code=code, reason=reason))

def onerror(ws, code, reason):
logging.info("Connection error: {code} - {reason}".format(code=code, reason=reason))

def onreconnect(ws, attempts_count):
logging.info("Reconnecting: {}".format(attempts_count))

def onnoreconnect(ws):
logging.info("Reconnect failed.")

def getticks(apikey, accesstoken):
kt = KiteTicker(api_key=apikey, access_token=accesstoken)
logging.basicConfig(level=logging.DEBUG)

# Assign the callbacks
kt.on_ticks = onticks
kt.on_connect = onconnect
kt.on_close = onclose
kt.on_error = onerror
kt.on_reconnect = onreconnect
kt.on_noreconnect = onnoreconnect

kt.connect()
  • rakeshr
    def getticks(apikey, accesstoken):
    kt = KiteTicker(api_key=apikey, access_token=accesstoken)
    logging.basicConfig(level=logging.DEBUG)
    You need to call getticks(apikey, accesstoken) method at first, to Initialise the ticker instance, as per your code flow.
  • deadlock
    deadlock edited October 2022
    Yes, I do that in main.py shown as follows:
    main.py
    import ticker
    ticker.getticks(apikey, data['access_token'])

    ticker.py
    def getticks(apikey, accesstoken):
    kt = KiteTicker(api_key=apikey, access_token=accesstoken)
    logging.basicConfig(level=logging.DEBUG)

    # Assign the callbacks
    kt.on_ticks = onticks
    kt.on_connect = onconnect
    kt.on_close = onclose
    kt.on_error = onerror
    kt.on_reconnect = onreconnect
    kt.on_noreconnect = onnoreconnect

    kt.connect()

    The kt = KiteTicker(apikey, accesstoken) call and the assign callbacks are all inside the getticks() method. I am unable to indent the code properly here.

    Kindly help. There is not much information to proceed.
  • deadlock
    I am endlessly waiting for hints to help troubleshoot. Why is the kiteticker.connect() call not going through?
  • sujith
    @deadlock,
    We don't provide programming support on the forum.
  • deadlock
    @sujith:
    I am looking for precise and timely Zerodha support on Kite API. I think that is reasonable to expect.

    KiteTicker.connect(), an API call, is failing to connect. I have attached my code only because it helps to understand and locate the issue. The code as such was running fine on Friday and also today early morning - much before market open. onticks() was receiving the last tick 15:29:59 from Friday. Therefore, there was no connection issue on kiteticker.connect(). So, no, I was not looking for programming support from Zerodha admins on this forum. At about 8.45, I have started receiving connection issue on KiteTicker.connect() call.

    I beg to defer. Please resolve my issue.
  • deadlock
    @sujith: Thumbs down !
    After market hours, the web socket connection was established on its own. Instead of admitting that there can be some issue with Zerodha servers, or, allowing other admins to help, you send an unsolicited reply to my thread. Also, no one replies to my query after that.

    This kind of attitude and non-transparency at work is not appreciated and hence voiced.
  • sujith
    @deadlock,
    This is a community driven forum and we are all developers like you who work on our own projects and take out sometime to help out fellow community members. Zerodha doesn't provide one to one support for writing solutions or strategies.

    Kite Ticker is working fine from our end and it is being used by thousands of production applications which includes our platforms and third-party platforms.
  • deadlock
    deadlock edited October 2022
    @sujith:
    What is mentioned in first para is understood and respected without any doubt. However, since you and other admins/moderators represent Zerodha, it is not an ethical practice to ignore a thread from someone whose is providing a feedback and asking for precise replies to issues. I was left whole day unattended, unaddressed and on my own. One admin did post one reply to my issue. That reply, however, was not relevant. So, I posted a follow-up with more details to explain that the suggestion from the admin may not be a problem. I also provided a feedback, which triggered a post from you. Unfortunately, instead of providing a new suggestion or hint to resolve my issue, I am surprised to find that your post is basically meant to ignore the thread by incorrectly suggesting that I am asking for programming support. I never asked for such support. A Zerodha API call was failing an entire day and other APIs worked fine. The login credentials were passed correctly as much as I could tell. Only the web socket connection failed, which was a show-stopper, and a Level 1 issue. Still, two Zerodha moderators ignored my issue. So, how did you really help me? Please let me know. If this issue occurs once again today, what am I supposed to do? Do I waste one more day on an issue related to KiteTicker.connect() call, a Zerodha API call that I have no control over. I do not imply that my code is perfect. But, the same code made a successful web socket connection at 15:33 PM, after market hours. Explain that to me. If Zerodha production platform and third-party platforms are in good running status, that does not imply that Zerodha servers are not failing to establish a connection for some clients. That also does not mean that my code is not erring. The replies from Zerodha moderators should be helpful to its customers to effectively make use of their APIs, a service that is not provided for free by the company.

    This forum is a platform provided by Zerodha as an offline support feature and it is marketed as such for retaining existing clients and acquiring new ones from their competitors. It is not purely a community driven forum as you are trying to make out to be. You seem to represent to Zerodha. So, please be kind enough to help me with suggestions to the extent feasible. I was merely trying to get pass a hurdle, a Zerodha API call, that was failing for two hours before I even posted a discussion thread. End of the day, Zerodha did not help me. How do I move forward with my work at this rate?
  • rakeshr
    rakeshr edited October 2022
    We have replied to your query on this thread. Go through it and please post all further related replies/queries on the same thread instead of creating multiple threads.
    The delay is caused here because of not posting complete code flow(including error logs) at once i.e in breaking sets making it difficult for us to understand it wholly to debug, leading to further questionnaires from our side to access. And creating multiple threads with all unrelated errors consumes time for both of us. In the future, make sure to have a single thread for one query, so it's easy to track and follow.
    Also, as said above by @sujith, we don't provide 1:1 coding assistance. Enough, examples and FAQs resources are available to handle all major queries.
This discussion has been closed.