Reactor error in websocket

astroamanj
Hi using the following code for MCX Lead and MCX Zinc I am getting the following error:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import logging
from kiteconnect import KiteTicker
logging.basicConfig(level=logging.DEBUG)

kws = KiteTicker("your_api_key", "your_access_token")

def on_ticks(ws, ticks):
logging.debug("Ticks: {}".format(ticks))

def on_connect(ws, response):
ws.subscribe([53987079, 53986055])
#ws.set_mode(ws.MODE_FULL, [53987079])

def on_close(ws, code, reason):
ws.stop()

# Assign the callbacks.
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()
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#ERROR#

>>> kws.connect()
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\ajakhar\AppData\Local\Programs\Python\Python36\lib\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\ticker.py", line 532, in connect
File "C:\Users\ajakhar\AppData\Local\Programs\Python\Python36\lib\site-packages\twisted\internet\base.py", line 1242, in run
self.startRunning(installSignalHandlers=installSignalHandlers)
File "C:\Users\ajakhar\AppData\Local\Programs\Python\Python36\lib\site-packages\twisted\internet\base.py", line 1222, in startRunning
ReactorBase.startRunning(self)
File "C:\Users\ajakhar\AppData\Local\Programs\Python\Python36\lib\site-packages\twisted\internet\base.py", line 730, in startRunning
raise error.ReactorNotRestartable()
twisted.internet.error.ReactorNotRestartable
Sign In or Register to comment.