@sizzmht If you are building a console app, logs will be printed in the console. If you are building a WinForms application you can see logs in Debug -> Windows -> Output.
To resolve issues faster you should provide us with more information like what were you trying to do, what are the instruments you were subscribing to, code example that can reproduce the problem, is there is any pattern in happening this error etc.
The more you can communicate and give us details, the faster we can help.
using System; using KiteConnect; using System.Collections.Generic;
namespace KiteConnectSample { class Program { // instances of Kite and Ticker static Ticker ticker; static Kite kite;
// Initialize key and secret of your app
static string MyUserId = "ZM7819";
// persist these data in settings or db or file static string MyPublicToken = "abcdefghijklmnopqrstuvwxyz"; static string MyAccessToken = "abcdefghijklmnopqrstuvwxyz";
@tonystark i have pasted entire code and console screenshot, let me know if you need anything else, i would appreciate your quick response. thanks. its the same code what is there on git hub i am just requesting banks tick data
Can you also give more information about your setup and library version?
static void Main(string[] args)
{
kite = new Kite(MyAPIKey, Debug: true);
// For handling 403 errors
kite.SetSessionExpiryHook(OnTokenExpire);
// Initializes the login flow
try
{
initSession();
}
catch (Exception e)
{
// Cannot continue without proper authentication
Console.WriteLine(e.Message);
Console.ReadKey();
Environment.Exit(0);
}
kite.SetAccessToken(MyAccessToken);
kite.EnableLogging(true);
// Initialize ticker
initTicker();
To resolve issues faster you should provide us with more information like what were you trying to do, what are the instruments you were subscribing to, code example that can reproduce the problem, is there is any pattern in happening this error etc.
The more you can communicate and give us details, the faster we can help.
using KiteConnect;
using System.Collections.Generic;
namespace KiteConnectSample
{
class Program
{
// instances of Kite and Ticker
static Ticker ticker;
static Kite kite;
// Initialize key and secret of your app
static string MyUserId = "ZM7819";
// persist these data in settings or db or file
static string MyPublicToken = "abcdefghijklmnopqrstuvwxyz";
static string MyAccessToken = "abcdefghijklmnopqrstuvwxyz";
static void Main(string[] args)
{
kite = new Kite(MyAPIKey, Debug: true);
// For handling 403 errors
kite.SetSessionExpiryHook(OnTokenExpire);
// Initializes the login flow
try
{
initSession();
}
catch (Exception e)
{
// Cannot continue without proper authentication
Console.WriteLine(e.Message);
Console.ReadKey();
Environment.Exit(0);
}
kite.SetAccessToken(MyAccessToken);
kite.EnableLogging(true);
// Initialize ticker
initTicker();
Console.ReadLine();
// Disconnect from ticker
ticker.Close();
}
private static void initSession()
{
Console.WriteLine("Goto " + kite.GetLoginURL());
Console.WriteLine("Enter request token: ");
string requestToken = Console.ReadLine();
User user = kite.GenerateSession(requestToken, MySecret);
kite.EnableLogging(true);
Console.WriteLine(Utils.JsonSerialize(user));
MyAccessToken = user.AccessToken;
MyPublicToken = user.PublicToken;
}
private static void initTicker()
{
ticker = new Ticker(MyAPIKey, MyAccessToken);
//ticker.OnTick += OnTick;
ticker.OnReconnect += OnReconnect;
ticker.OnNoReconnect += OnNoReconnect;
ticker.OnError += OnError;
ticker.OnClose += OnClose;
ticker.OnConnect += OnConnect;
ticker.OnOrderUpdate += OnOrderUpdate;
ticker.EnableReconnect(Interval: 5, Retries: 50);
ticker.Connect();
// Subscribing to NIFTY50 and setting mode to LTP
ticker.Subscribe(Tokens: new UInt32[] { 1510401, 779521, 1270529, 341249, 492033, 1195009, 261889, 3050241, 1346049 });
ticker.SetMode(Tokens: new UInt32[] { 1510401, 779521, 1270529, 341249, 492033, 1195009, 261889, 3050241, 1346049 }, Mode: Constants.MODE_FULL);
}
private static void OnTokenExpire()
{
Console.WriteLine("Need to login again");
}
private static void OnConnect()
{
Console.WriteLine("Connected ticker");
}
private static void OnClose()
{
Console.WriteLine("Closed ticker");
}
private static void OnError(string Message)
{
Console.WriteLine("Error: " + Message);
}
private static void OnNoReconnect()
{
Console.WriteLine("Not reconnecting");
}
private static void OnReconnect()
{
Console.WriteLine("Reconnecting");
}
private static void OnTick(Tick TickData)
{
Console.WriteLine("Tick " + Utils.JsonSerialize(TickData));
}
private static void OnOrderUpdate(Order OrderData)
{
Console.WriteLine("OrderUpdate " + Utils.JsonSerialize(OrderData));
}
}
}
ticker = new Ticker(MyAPIKey, MyAccessToken, Debug: true);
?This will log more details about what is happening in ticker.
//ticker.OnTick += OnTick;
. All events in ticker are mandatory to have a handler. Try uncommenting it as well.