Default Python Client code for Websocket not working

I copy pasted the sample in the docs as follows:

from kiteconnect import WebSocket

kws = WebSocket("XXXX", "XXXX", "XXXXX")

# Callback for tick reception.
def on_tick(tick, ws):
print tick

# Callback for successful connection.
def on_connect(ws):
# 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])

# Assign the callbacks.
kws.on_tick = on_tick
kws.on_connect = on_connect

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

I just get the following output:

and the program exits.

There is no infinite loop as mentioned in the documentation.

Any help would be greatly appreciated.
  • Kailash
    Have you correctly installed the kiteconnect library using pip?
  • mightymosquito

    this is what pip freeze looks like(in a virtualenv):
  • mightymosquito
    Just figured out the root url does not connect on wss://,

    Working fine with ws://
  • Kailash
    @mightymosquito 'ws' (insecure) is just a test endpoint and will be deprecated in the near future. if wss (secure / https) isn't working, there must be some issue with the root certificates on your system, which you should try and resolve.
Sign In or Register to comment.