Websocket Streaming Error - Reactor Not Restrtable

Anuj
Anuj edited February 2018 in Market data (WebSockets)
Hi Vivek,

I am using your code (exact copy/paste from another thread) but am still getting the Reactor not Restartable error. Pl


The code is:
from kiteconnect import KiteTicker, KiteConnect

logging.basicConfig(level=logging.DEBUG)

def init(api_key, api_secret):
kite = KiteConnect(api_key=api_key)
request_token="abc"
data = kite.generate_session(request_token, api_secret)
kite.set_access_token(data["access_token"])
return data["access_token"]

# Initialise
api_key="abc"
api_secret="abc"
access_token=init(api_key, api_secret)

kws = KiteTicker(api_key, access_token, debug=True)

def on_ticks(ws, ticks):
print(ticks)

def on_connect(ws, response):
logging.debug("on connect: {}".format(response))
ws.subscribe([738561, 5633])
ws.set_mode(ws.MODE_FULL, [738561])


def on_close(ws, code, reason):
logging.error("closed connection on close: {} {}".format(code, reason))


def on_error(ws, code, reason):
logging.error("closed connection on error: {} {}".format(code, reason))


def on_noreconnect(ws):
logging.error("Reconnecting the websocket failed")


def on_reconnect(ws, attempt_count):
logging.debug("Reconnecting the websocket: {}".format(attempt_count))


def on_order_update(ws, data):
print("order update: ", data)

# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close
kws.on_error = on_error
kws.on_noreconnect = on_noreconnect
kws.on_reconnect = on_reconnect
kws.on_order_update = on_order_update


# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect()


  • Anuj
    @sujith . can you please help out?
  • sujith
    Can you mention which version of pykiteconnect you are using and paste the complete logs with details about the machine you are using?
  • Anuj
    Hi @sujith , Am using version 3.0 of pykiteconnect. Though this seems to work now - weird because I have not made any changes to the code at all. Anyway, thanks for your help. Please treat this issue as resolved.

This discussion has been closed.