How to use websocket

harjee
Hi All, i am new to java programming..can anyone please guide me on how to use the websocket for obtaining tick data using kiteconnect java library..tried using the example provided in github but that throws an exception ..
com.rainmatter.kitehttp.exceptions.KiteException
at com.rainmatter.ticker.KiteTicker.subscribe(KiteTicker.java:277)
at com.harjee.Examples$9.onConnected(Examples.java:362)
at com.rainmatter.ticker.KiteTicker$2.onConnected(KiteTicker.java:157)
at com.neovisionaries.ws.client.ListenerManager.callOnConnected(ListenerManager.java:76)
at com.neovisionaries.ws.client.WebSocket.callOnConnectedIfNotYet(WebSocket.java:2177)
at com.neovisionaries.ws.client.WebSocket.onReadingThreadStarted(WebSocket.java:2132)
at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:78)
at com.neovisionaries.ws.client.ReadingThread.run(ReadingThread.java:59)

pls help..thanks
  • sujith
    Hi @harjee,
    Can you print kiteException.message?
  • harjee
    sorry sujith .. not understood your answer..have included the netbeans debugger output in my origimnal message
  • sujith
    HI @harjee,
    Check out structure of Kite Exception here.
    Print message and post it here.
  • harjee
    Hi, i set a breakpoint in the KiteException.java file and got the following
    message="ticker is not connected"
    code=504
    pls help. thanks
  • sujith
    You need to subscribe after Websocket is connected.
  • harjee
    didnt understand that..pardon my ignorance..but could you give a bit more detail..i am just using the example provided as it is..why it doesnt work?
  • sujith
    Are you sure, you are calling connect method?
    Can you paste your code here?
  • harjee
    Hi Sujith, i am simply using the exact code as given in the example file (Test.java & Examples.java) at github. i havnt made any change other than the key, access token etc. so i dont understand why it doesnt work :(
  • sujith
    Hi @harjee,
    Please go through the code, it is a working example which we use for testing.
    You must be missing something. Please read and understand stuff before you implement it.

    Once you call ticker.connect(), an onConnected callback is called, try logging inside that and check if it is connected.
  • harjee
    Ok will come back to you..dont close this discussion please..thanks
  • harjee
    thanks Sujith for all the help..was making a stupid mistake at my end..at least this problem is resolved..thanks once again
This discussion has been closed.