The operation has timed out error

TradeM
Hello,
While using .net client App, i have started getting "'The operation has timed out." error recently. Any idea what could be cause for this? There is no network issue here.
  • tonystark
    The above error message is not thrown by the library exceptions. It must be from the .Net framework or by the system.

    Please post exception stack trace or a code snippet that can reproduce the issue at our end. It is difficult to pinpoint the issue just from an error message.
  • TradeM
    Please see below. Do you think this could be due to certain windows security updates? My system did install few updates recently
    ======================
    System.Net.WebException
    HResult=0x80131509
    Message=The operation has timed out.
    Source=KiteConnect
    StackTrace:
    at KiteConnect.Kite.Request(String Route, String Method, Object Params, Dictionary`2 QueryParams, Boolean json) in C:\Chetan\Trade\KiteConnect\Backup\dotnetkiteconnect-master - 8 - Good\KiteConnect\Kite.cs:line 1281
    at KiteConnect.Kite.Get(String Route, Dictionary`2 Params, Dictionary`2 QueryParams) in C:\Chetan\Trade\KiteConnect\Backup\dotnetkiteconnect-master - 8 - Good\KiteConnect\Kite.cs:line 1122
    at KiteConnect.Kite.GetLTP(String[] InstrumentId) in C:\Chetan\Trade\KiteConnect\Backup\dotnetkiteconnect-master - 8 - Good\KiteConnect\Kite.cs:line 690
    at KiteConnectSample.Program.Main(String[] args) in C:\Chetan\Trade\KiteConnect\Backup\dotnetkiteconnect-master - 8 - Good\KiteConnectSample\Program.cs:line 389
  • tonystark
    tonystark edited November 2022
    This seem like a network timeout. Program is unable to initiate a connection to Kite even after a long time.

    I'm unsure if security updates can cause this. But if there was any changes to your network/firewall/internet/DNS settings then this can happen. Couple of things to try:

    1. Try opening https://api.kite.trade/ in browser. If this loads then it is not internet issue.
    2. Try `ping api.kite.trade` in command prompt. If this works then your DNS is fine.
    3. Try a new sample project and see if that is able to access Kite data. If this works then your firewall has blocked your main program.
  • TradeM
    1 & 2 are fine. I have put all firewall settings off.

    Also, i am getting below error intermittently. Any thoughts? I am clueless as to why i started getting these errors from last couple of days.

    ================
    System.OperationCanceledException
    HResult=0x8013153B
    Message=The operation was canceled.
    Source=System.Net.Requests
    StackTrace:
    at System.Net.HttpWebRequest.GetResponse()
    at KiteConnect.Kite.Request(String Route, String Method, Object Params, Dictionary`2 QueryParams, Boolean json) in C:\Chetan\Trade\KiteConnect\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 1274
    at KiteConnect.Kite.Get(String Route, Dictionary`2 Params, Dictionary`2 QueryParams) in C:\Chetan\Trade\KiteConnect\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 1122
    at KiteConnect.Kite.GetLTP(String[] InstrumentId) in C:\Chetan\Trade\KiteConnect\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 690
    at KiteConnectSample.Program.Main(String[] args) in C:\Chetan\Trade\KiteConnect\dotnetkiteconnect-master\KiteConnectSample\Program.cs:line 494
  • TradeM
    And remember, these are happening randomly. The same GetLTP API works fine sometimes and throws "Operation was cancelled" / "Operation time out" errors other times.
  • tonystark
    From the documentation it looks like `OperationCanceledException` is pretty much same as timeout exception.
  • TradeM
    What do you mean by these exceptions are pretty much same? There got to be different logic when two different exceptions are raised.
  • tonystark
    I meant they seem to trigger due to the same reasons. And they are hard to distinguish. Ref: https://stackoverflow.com/questions/35615638/any-way-to-differentiate-cancel-and-timeout
  • TradeM
    Hey tonystark,
    My user ID is PJR394. Now I am continuously getting time out error.. here is call stack. Any help you could provide is much appreciated.
    I downloaded fresh kiteconnect sample from github.. changed network etc. to eliminate that possibility. No luck.
    ========================
    System.Net.WebException
    HResult=0x80131509
    Message=The operation has timed out.
    Source=System.Net.Requests
    StackTrace:
    at System.Net.HttpWebRequest.GetResponse()
    at KiteConnect.Kite.Request(String Route, String Method, Object Params, Dictionary`2 QueryParams, Boolean json) in C:\Chetan\Trade\KiteConnect\Original\dotnetkiteconnect-master\KiteConnect\Kite.cs:line 1274

    This exception was originally thrown at this call stack:
    [External Code]
    KiteConnect.Kite.Request(string, string, dynamic, System.Collections.Generic.Dictionary, bool) in Kite.cs
  • TradeM
    Here is piece of code that throws time out exception:

    try
    {
    webResponse = request.GetResponse();
    }
    catch (WebException e)
    {
    if (e.Response is null)
    throw e;

    webResponse = e.Response;
    }
  • tonystark
    If the sample code itself is throwing the error then I'm out of ideas. :(

    May be you should try in a different machine while being in the same network. See if that works.
  • TradeM
    For benefits of community, this was due to mcafee software. Mcafee is such a shitty product. Their product can't be uninstalled by Windows standard uninstall procedure and therefore they created utility called MCPR. Such a BS.
This discussion has been closed.