Fyers API Websocket : whats wrong with my code?

Hello coders. I am able to login and generate token. Also quotes are coming but websocket is not fetching any live data. Can anyone help me find out whats wrong with my code?

It is not giving any error. Fetching recent quotes single time but not live data.

app_id = "*******"
app_secret = "*******"
redirect_uri = "https://trade.fyers.in/api-login/redirect-uri/index.html"

from fyers_api import fyersModel, accessToken
from fyers_api.Websocket import ws
import os

def get_access_token():
	if not os.path.exists("access_token.txt"):
		session = accessToken.SessionModel(client_id=app_id, secret_key=app_secret, redirect_uri=redirect_uri, response_type="code", grant_type="authorization_code")
		response = session.generate_authcode()
		print("Login Url: ", response)
		auth_code = input("Enter Auth Code : ")
		session.set_token(auth_code)
		access_token = session.generate_token()["access_token"]
		with open("access_token.txt", "w") as f:
			f.write(access_token)
	else:
		with open("access_token.txt", "r") as f:
			access_token = f.read()
	return access_token


fyers = fyersModel.FyersModel(client_id=app_id, token=get_access_token(), log_path=" ")

data= {"symbols": "MCX:SILVERMIC23JUNFUT"}
print (fyers.quotes(data))


from fyers_api.Websocket import ws
client_id=open('****\\app_id.txt','r').read()
token=open('*****\\access_token.txt','r').read().strip()
access_token = client_id+":"+token
data_type = 'symbolData'
symbol = ['MCX:SILVERMIC23JUNFUT', 'NSE:SBI-EQ']
def custom_message(ticks):
	print(ticks)

fs = ws.FyersSocket(access_token,run_background=False,log_path='*****')
fs.websocket_data = custom_message
fs.subscribe(symbol,data_type)

1 reply