jugaad-trader icon indicating copy to clipboard operation
jugaad-trader copied to clipboard

Not able to connect to ticker

Open MaheshCodeReader opened this issue 3 years ago • 12 comments

Not able to connect to ticker

MaheshCodeReader avatar Jul 28 '21 05:07 MaheshCodeReader

I guess this is a temporary error from Zerodha sides. Now it is working fine.

luckyIITR avatar Jul 29 '21 07:07 luckyIITR

I'm also not able to connect to ticker. @luckyIITR How did you fix it?

kool4u avatar Jul 29 '21 17:07 kool4u

enc_token is modified only for kite ticker.

enc_token = enc_token.replace("+", "%2B") enc_token = enc_token.replace("/", "%2F") enc_token = enc_token.replace("=", "%3D")

This worked for me.

luckyIITR avatar Jul 30 '21 06:07 luckyIITR

Which KiteConnect version are you using? Is this change to be done for older version or 2.9.2?

I modified this method as per your suggestion, still not working.

def ticker(self, api_key='kitefront', enctoken=None, userid=None):

    if enctoken is not None:
        self.enctoken = self.r.cookies['enc_token']
    if userid is not None:
        self.user_id = self.user_id
    if self.user_id is None:
        raise Exception("\nCould not find the session, Please start a session using \n\n$ jtrader zerodha startsession")
        
    enc_token = self.enc_token.replace("+", "%2B")
    enc_token = enc_token.replace("/", "%2F")
    enc_token = enc_token.replace("=", "%3D")
    
    return KiteTicker(api_key=api_key, access_token=enc_token+'&user_id='+self.user_id, root='wss://ws.zerodha.com')

kool4u avatar Jul 30 '21 09:07 kool4u

Its working for me.. I just updated Kite to latest version without any modification to enc_token.

def on_ticks(ws, ticks): # Callback to receive ticks. print(ticks) #print(kws.is_connected()) 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])

# 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. ##You have to use the pre-defined callbacks to manage subscriptions. kws.connect()

code copied from here.. it was not displaying anything initially so for testing i have directed printed ticks parameter.. https://kite.trade/docs/pykiteconnect/v3/ticker.m.html

ssheikh098 avatar Aug 23 '21 06:08 ssheikh098

@ssheikh098 @luckyIITR How is ticker working for you guys ? I am getting below error : Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (400 - BadRequest))

smilinrobin avatar Sep 07 '21 13:09 smilinrobin

@smilinrobin For me, it is working fine. Keep in mind that if you disconnect the ticker once, you need to restart the kernel to start ticker again.

luckyIITR avatar Sep 07 '21 13:09 luckyIITR

@luckyIITR which version of KiteConnect are you using. Its not working on mine 3.8.2

$ pip3 list | grep kiteconnect kiteconnect 3.8.2

vishalpatil avatar Dec 20 '21 14:12 vishalpatil

Solved this by installing jugaad-trader from source. For some reason installation using pip doesn't work. May be there might be a need for version upgrade as the upgrade command doesn't work and I see the old source in the pip installation.

Steps followed:

  1. Clone from github
  2. cd to directory
  3. Installed using python3 setup.py install --prefix /home/user/.local/

vishalpatil avatar Dec 20 '21 14:12 vishalpatil

this issue persists. i tried to fix but going nowhere.

ashishanand7 avatar Jul 02 '22 13:07 ashishanand7

@ashishanand7

if this has not resolved, then try these steps - https://github.com/jugaad-py/jugaad-trader/issues/44#issuecomment-1200493371

this issue persists. i tried to fix but going nowhere.

ssheikh098 avatar Jul 31 '22 20:07 ssheikh098

Refer to this issue. This solution worked for me https://github.com/jugaad-py/jugaad-trader/issues/44#issuecomment-1200493371

PrajwalShenoy avatar Aug 18 '22 10:08 PrajwalShenoy