Websocket not giving any data


  • I have been trying to run a code to get live data using websocket but it is not giving any data other than hb signals. In the data variable it gives me the login information and everything else but the live data is not coming for some reason.

    from smartapi import SmartWebSocket
    import pyotp
    from smartapi import SmartConnect, SmartWebSocket
    
    
    api_key = <my_api_key>
    access_token = <access_token>
    client_code = <client_code>
    password = <password>
    totp = pyotp.TOTP(access_token).now()
    obj=SmartConnect(api_key=api_key)
    data = obj.generateSession(client_code, password, totp)
    
    feedToken=obj.getfeedToken()
    FEED_TOKEN=feedToken
    CLIENT_CODE=client_code
    token="nse_cm|3045"    
    task="mw"   
    
    ss = SmartWebSocket(FEED_TOKEN, CLIENT_CODE)
    
    def on_message(ws, message):
        print("Ticks: {}".format(message))
        
    def on_open(ws):
        print("on open")
        ss.subscribe(task,token)
        
    def on_error(ws, error):
        print(error)
        
    def on_close(ws):
        print("Close")
    
    # Assign the callbacks.
    ss._on_open = on_open
    ss._on_message = on_message
    ss._on_error = on_error
    ss._on_close = on_close
    
    ss.connect()
    
    # ss.ws.close()
    # obj.terminateSession(client_code)
    
    __on_open################
    {'task': 'cn', 'channel': 'NONLM', 'token': '0886678803', 'user': 'RIST1049', 'acctid': 'RIST1049'}
    2023-03-09 08:43:38.808472 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '0886678803', 'user': 'RIST1049', 'acctid': 'RIST1049'}
    on open
    2023-03-09 08:43:55.397606 : Start task in the background