Operation Timed Out in GenerateSession

Nighar
I downloaded the .Net KiteConnect solution and after inserting my apikey and api secret it connected successfully once yesterday, but today it is timing out in Kite.GenerateSession. I have tried multiple times and always get the same error.
  • sujith
    Can you run it in debug mode and paste the complete stack trace?

    PS: Make sure you don't paste app or user-specific details from the logs.
  • Nighar
    The operation has timed out
    at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
    at System.Net.HttpWebRequest.GetRequestStream()
    at KiteConnect.Kite.Request(String Route, String Method, Dictionary`2 Params) in [path]\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 1157
    at KiteConnect.Kite.Post(String Route, Dictionary`2 Params) in [path]\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 1057
    at KiteConnect.Kite.GenerateSession(String RequestToken, String AppSecret) in [path]\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 174
    at KiteConnectSample.Program.initSession() in [path]\dotnetkiteconnect-master\KiteConnectSample\Program.cs:line 393
    at KiteConnectSample.Program.Main(String[] args) in [path]\dotnetkiteconnect-master\KiteConnectSample\Program.cs:line 35
  • Nighar
    Hi Sujith,

    Any update on this issue?
  • tonystark
    This seems to be a client specific issue. Can you post the debug logs? You can enable them by adding Debug: True to the Kite constructor. What you posted is the exception stack trace which doesn't have enough info to identify the cause.

    Also that sample project is suppose to be a reference and not a demo. When you run it make sure you know what is getting executed.

    Thanks
  • Nighar
    Below is the complete output in the console window when I run the KiteConnectSample project. I have replaced the actual api key, secret and request token with place holders in [].

    Goto https://kite.trade/connect/login?api_key=[API_KEY]&v=3
    Enter request token:
    [REQUEST_TOKEN]
    [API_KEY][REQUEST_TOKEN][APP_SECRET]
    DEBUG: POST https://api.kite.trade/session/token
    api_key=[API_KEY]&request_token=[REQUEST_TOKEN]&checksum=e89d4e75761c7985895013cf5c4415769695c2728e0db9cbd7244b65ba3c55f2
    DEBUG: Content-Type: application/x-www-form-urlencoded
    DEBUG: User-Agent: KiteConnect.Net/3.0.4.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token [API_KEY]:
    The operation has timed out
    at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
    at System.Net.HttpWebRequest.GetRequestStream()
    at KiteConnect.Kite.Request(String Route, String Method, Dictionary`2 Params) in [path]\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 1157
    at KiteConnect.Kite.Post(String Route, Dictionary`2 Params) in [path]\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 1057
    at KiteConnect.Kite.GenerateSession(String RequestToken, String AppSecret) in [path]\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 174
    at KiteConnectSample.Program.initSession() in [path]\dotnetkiteconnect-master\KiteConnectSample\Program.cs:line 393
    at KiteConnectSample.Program.Main(String[] args) in [path]\dotnetkiteconnect-master\KiteConnectSample\Program.cs:line 35
  • Nighar
    To check whether the issue is with my PC, I tried on a different laptop. Below are the exact steps I followed and the results.

    1) Downloaded dotnetkiteconnect-master.zip from https://github.com/zerodhatech/dotnetkiteconnect/ (link taken from https://kite.trade/docs/connect/v3/)
    2) Updated my API Key and App Secret in KiteConnectSample project and ran it in Debug mode
    3) It connected to the API fine
    4) Now in my other Solution (different from the sample downloaded in step 1 above), I installed Tech.Zerodha.KiteConnect nuget package as per the instructions in https://github.com/zerodhatech/dotnetkiteconnect/
    5) I then tried to connect to the api using the same API Key and App Secret as used in step 2 above, but Exception was thrown with "Operation Timed Out" in GenerateSession method.
    6) Now I go back to the sample solution in step 1 and run it again and this time it throws Exception with "Operation Timed Out" in GenerateSession method.
    7) I tried multiple times to execute the KiteConnectSample project and it always threw the same Exception in the same method.
    8) I restarted the laptop, executed the KiteConnectSample project and it connected to the API fine.
    9) Now I ran the code in my other solution (from step 4 above) that uses the nuget pack and it again times out at the same step.
    10) Again run the KiteConnectSample project and it times out too

    Based on the above steps and results it seems to be there is something wrong with the nuget package. Now my question is does the KiteConnect project in the dotnetkiteconnect-master.zip file have all the functionality of the API and can I include this project in my solution and use it without having to install the nuget package?

    Thank you.
  • tonystark
    @Nighar This is strange. Seems like something is blocking internet connectivity for that DLL. Do you have any antivirus or firewall system running?

    And yes you can add that project and use. DLL is built from that and has the same functionality.
Sign In or Register to comment.