Getting error: ReactorNotRestartable

dheer
Environment Python:
IDE: Spyder
OS: Windows 10


I am using the sample skeleton provided here: https://kite.trade/docs/pykiteconnect/v3/#kiteconnect.KiteTicker

I have double checked the credentials (both, API key and Access Token). I am using the correct ones. I am still getting below error:

kws.connect()

File "C:\Users\dheer_thakkar\Anaconda3\lib\site-packages\kiteconnect\ticker.py", line 532, in connect
reactor.run(**opts)

File "C:\Users\dheer_thakkar\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1282, in run
self.startRunning(installSignalHandlers=installSignalHandlers)

File "C:\Users\dheer_thakkar\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1262, in startRunning
ReactorBase.startRunning(self)

File "C:\Users\dheer_thakkar\Anaconda3\lib\site-packages\twisted\internet\base.py", line 765, in startRunning
raise error.ReactorNotRestartable()

ReactorNotRestartable



Also a point to note: Whenever the code is run first time in Spyder, I get below error:
ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))

after this, I get the ReactorNotRestartable error

Could you please help me resolve this?
  • sujith
    403 means, your session seems to be expired. You need to get a new access token.
  • dheer
    dheer edited January 2021
    @sujith
    1. yesterday, It gave me the same access token every time I followed the steps to fetch one.
    2. it gave me a new one today, but the issue still persists.
  • sujith
    Are you sure, you are not calling generate_session every time you run the app?
  • dheer
    dheer edited January 2021
    @sujith

    Yes. I run generate session just once. To get the access token:

    api_k = "my api key" # api_key
    api_s = "my api secret" # api_secret

    global kite
    kite = KiteConnect(api_key=api_k)

    print("[*] Generate access Token : ", kite.login_url())
    -->this gives me the URL. I go to this URL, login, and get my request token

    request_tkn = input("[*] Enter Your Request Token Here : ")
    -->I put my request token here

    data = kite.generate_session(request_tkn, api_secret=api_s)
    -->pickup access token from here here

    print(data['access_token'])


    This code is run only once.

    after this I use the access token to run the skeleton I mentioned above.

    And every time I do that, I get this error:
    ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
  • dheer
    dheer edited January 2021
    @sujith

    Even tried step by step instructions on this page to get the access token - https://kite.trade/docs/connect/v3/user/#login-flow

    Still same error
    ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
  • sujith
    Can you private message the api_key, client_id, and access token you are passing?
Sign In or Register to comment.