I am assuming that the access token once obtained can be used in other sessions (subject to a single session being active) till it gets invalidated which I guess is once per day. I can also see this is a valid assumption, since whenever I launch the Kite Connect .Net library, login from browser and pass the request token back into the code, I get back the same access token that I got when I connected for the very first time.
So by using your library, I could connect fine and get the quotes. However, when I tried to call the C# API dll (KiteConnect.dll) from a VB.Net front end, I get errors that the connection is being refused.
So, I separated out the raw websocket code from your C# library that handles the connection. It goes like this: //TO DO: Remove the below direct web socket creation ClientWebSocket ws = new ClientWebSocket(); ws.Options.SetRequestHeader("X-Kite-Version", "3"); ws.ConnectAsync(new Uri("wss://ws.kite.trade/?api_key=<<api key>>&access_token=<<access_token>>"), CancellationToken.None).Wait(); Console.WriteLine("OK");
The above works fine.
Now the same code in Vb.Net Dim ws = New ClientWebSocket() ws.Options.SetRequestHeader("X-Kite-Version", "3") ws.ConnectAsync(New Uri("wss://ws.kite.trade/?api_key=<<api_key>>&access_token=<<access_token>>"), CancellationToken.None).Wait() Console.WriteLine("OK")
This generates the below exception: Error while connecting. Message: No connection could be made because the target machine actively refused it 127.0.0.1:8888
Please note that the api key and access token are exactly the same in both the versions. Why am I getting this error?