Announcement

Collapse
No announcement yet.

Lots of UNEXPECTED_ERRORS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lots of UNEXPECTED_ERRORS

    Hi

    Recently my daily log file has been full of intermittent APIING Exceptions of the ErrorCode: UNEXPECTED_ERROR.

    I am not sure what could be the cause of these errors as obviously I would have a more detailed message from APIING if they could give me one, I hope!

    I have a method I call in all APIING Exceptions Catch handlers to check the error code thrown and then decide whether to throw it e.g (TOO_MUCH_DATA, INVALID_DATA_INPUT),

    kill all my objects in my BOT and re-create them and then re-login e.g INVALID_SESSION_INFORMATION, NO_SESSION, NO_APP_KEY, INVALID_APP_KEY

    Or wait a bit and retry the current operation which is what I do with UNEXPECTED_ERROR as well as TIMEOUT_ERROR or SERVICE_BUSY.

    Does anyone have any clue to what causes these UNEXPECTED_ERRORS or what the best cause of action when getting them is?

    Thanks for any help in advance.....

  • #2
    Unexpected errors

    If the markets have been on the Australian exchange it could be due to ongoing instability there - I have had issues off and on since last Saturday, mainly between 10 am and 3pm Aust time.

    First thing to do if you have any strange issues is to check the Betfair api status page:

    http://status.developer.betfair.com/

    right now it is showing this message for the Australian Exchange:

    /listCurrentOrders Operational /listMarketBook Performance Issues

    "Performance Issues" usually results in markets not returned

    Comment


    • #3
      Cheers bit

      Cheers but I am not using the Australian exchange.

      These have been intermittent errors for the last week or so now.

      I do check the status page but parts of the API will work like getting prices, markets, placing bets and then I will just get an unexpected_error all of the sudden.

      As there was no simple way of finding out which method had thrown the exception without analysing the stack trace I put an extra param into all calls to this handler and it seems that the issue is when I try to access my wallet to get current account funds. Why I don't know.

      I have a Windows Service and a little status bar form that allows me to stop/start the service as well as showing me current errors, if the API is running, last login time and the current account balance. There is a timer on that form that hooks into the same DLL as my BOT every minute and runs a "TestConnection" method that returns whether the API is up as well as connections to my databases and returns the current balance in my account. This helps me easily see what is going on without checking the log file.

      The stack trace shows that is the JsonRpcClient login method that is throwing the error for some reason when it tries to access the Wallet. Why I don't know as the next moment it will be fine and I have always got my balance showing correctly on the form e.g

      HandleAPIError from JsonRpcClient Login: UNEXPECTED_ERROR - Unknown Error Details
      at Api_ng_sample_code.JsonRpcClient.Invoke[T](String method, IDictionary`2 args) in [in path]

      at Api_ng_sample_code.JsonRpcClient.getAccountFunds(W allet walletName) in [in path]

      at Api_ng_sample_code.BetfairAPI.JsonRpcClientLogin() [in path]

      So line 294 is in my JsonRPCClient class on the test FOR an error inside my HTTP method to pass JSON to the API and get the response back e.g


      using (WebResponse response = GetWebResponse(request))
      using (Stream stream = response.GetResponseStream())
      using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
      {
      // try and get response
      var jsonResponse = JsonConvert.Import<T>(reader);

      // THIS LINE IS ERRORING? MAYBE THERE IS NO .HasError method on the JSON RESPONSE?
      if (jsonResponse.HasError)
      {
      // throw the error
      throw ReconstituteException(jsonResponse.Error);
      }
      else
      {
      return jsonResponse.Result;
      }
      }

      So the actual error is on the test for jsonResponse.HasError - I am guessing that for some reason the JSON object coming back from the API doesn't have that property on it which is throwing the error. Why it is always when I check the Wallet I don't know but this is the cause of the issue.

      This is a core method used to pass ALL calls to the API and get the JSON response back so it's working 99.9% of the time passing JSON for markets/placing bets/cancelling bets etc and getting account funds but every now and then it will throw this error.

      I could just wrap this test in a try/catch and ignore it as an API issue if the JSON is malformed instead of constantly logging it but I would like to know why it is not properly formed JSON.

      Ideas?

      Thanks

      Comment


      • #4
        Any chance of capturing the JSON strings that are going in each direction? If you've already got a logfile, can you arrange to add such things to either it or another file when there's a problem?

        Comment

        Working...
        X