WebSocket Connect example not working

manishv
Hi All

I've tried running the WebSocket connect example on Python 3.7. The IDLE screen goes blank on running the code with no streaming quotes shown. On pressing Ctrl C it shows a long error log with the following error message at the end. I am quite sure that i am using the correct api key and access token. Any help will be greatly appreciated!
Error Message:
py", line 647, in stop
"Can't stop reactor that isn't running.")
twisted.internet.error.ReactorNotRunning: Can't stop reactor that isn't running.

Example used:
import logging
from kiteconnect import KiteTicker
kws = KiteTicker(api_key, access_token)


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

def on_connect(ws, response):
# Callback on successful connect
# Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
ws.subscribe([738561, 5633])

# Set RELIANCE to tick in 'full' mode
ws.set_mode(ws.MODE_FULL, [738561])

def on_close(ws, code, reason):
# On connection close stop the event loop.
# Reconnection will not happen after executing `ws.stop()`
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.

  • manishv
    The program is working fine now. I had missed including this line in the code: logging.basicConfig(level=logging.DEBUG)
This discussion has been closed.