WebSocket streaming not working, need setup help.

siddu
I installed Python 3.5.2 on windows and KiteConnect V3.4, used the example shown in below link "https://github.com/rainmattertech/pykiteconnect" for streaming data. my observations

1. kite.connect() should be infinite loop but control reaching after the that call also,
2. getting call back in "on_error" and printed error "name "opcode" is not defined".

Need help to setup properly in my windows 10 machine.
Versions: requests-2.12.3,websocket_client-0.39.0,six-1.10.0.
  • sujith
    Hi @siddu,
    This shouldn't be happening now. Can you check now?
  • siddu
    HI @sujith,
    I checked again it still giving me same error. Can you update your environment and verify.

    Python on windows 64bit : 3.5 version.
    kiteconnect : V3.4
    Webscoket client: 0.39
    and the example

    #!python
    from kiteconnect import WebSocket

    # Initialise.
    kws = WebSocket("XXX", "XXXX", "XXX")

    # 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])

    # Set RELIANCE to tick in `full` mode.
    ws.set_mode(ws.MODE_FULL, [738561])
    def on_error(error,ws):
    print(error)
    # Assign the callbacks.
    kws.on_tick = on_tick
    kws.on_connect = on_connect
    kws.on_error = on_error

    # Infinite loop on the main thread. Nothing after this will run.
    # You have to use the pre-defined callbacks to manage subscriptions.
    kws.connect()
  • siddu
    And it seems to be issue in websocket-client, some one opened issue in the github page of websocket client 2 days ago.
    https://github.com/liris/websocket-client/issues/284

    @Sujit, what is the version of Websocket client you are using. Is there any way to get older version websocket client.
  • siddu
    At last i found where the issue is, it is with WebSocket client with respective Python 3. If you use python 2 and the same websocket client V0.39, i am able to receive streaming data. Took 2 days to locate issue. Will be useful for the guys who try with Phyton 3.
    https://github.com/liris/websocket-client/issues/284
    @ Sujit, Please test your kiteconnect python library with Python 3, i hope it wont work because of above issue and add a note to people to use Python 2.
  • sujith
    Hi @siddu,
    Thank you for notifying. We will look into this.
Sign In or Register to comment.