Jump to content
  • 2

Rest calls intermittent forbidden responses


svb

Question

Hi,

C# : use combination of REST & streaming. Replicated using WPF example that you can download in labs.

This issue is specific to REST

Every 15 minutes I get 15 min prices for a range of epics. My allowance is fine with +6500 left. 

I keep getting random null responses with "forbidden" status code. Different epics. If I trap null response and then set rest call to execute again, it works. I continue and it carried on with rest of epics, or will do say 10 , return forbidden for 3 and then return fine for epics following that. if I step through each epic, its fine. So seems to be some timing glitch. Tried trapping and adding task.delays and retries, but still null. I have to actually break and step over. Given its not my allowance, are there any quirks with REST calls to cause this? This is example, does some, throws forbidden and then fine for AUDCAD again.

persist 15: 17/03/2021 22:15:01 - CS.D.CADJPY.TODAY.IP
persist 15: 17/03/2021 22:15:01 - CS.D.CADCHF.TODAY.IP
persist 15: 17/03/2021 22:15:01 - CS.D.EURAUD.TODAY.IP
response is null for CS.D.NZDJPY.TODAY.IP 15
response is null for CS.D.NZDUSD.TODAY.IP 15
response is null for CS.D.CHFJPY.TODAY.IP 15
response is null for CS.D.USCGC.TODAY.IP 15
response is null for CC.D.CL.USS.IP 15
persist 15: 17/03/2021 22:15:01 - CS.D.AUDCAD.TODAY.IP

I cannot replicate forbidden status response in REST companion for any epic either, just seems when run via rest client

Thanks

Edited by svb
add note about running in companion
  • Like 2
Link to comment

8 answers to this question

Recommended Posts

  • 0

improved it by making sure rest calls aren't async and also putting 2 second wait before each call (1 second is not enough and I get more forbidden responses). For what I'm doing this is ok-ish, but not great. Given this is the rest client returning this and not my code I'm not sure what's changed i.e account, service validation. If anyone has any ideas that would be much appreciated,

the wait I added,

 

    foreach (var market in MarketList)
                        {
                            try
                            {
                                Thread.Sleep(2000);

                                response = await igRestApiClient.priceSearchByNumV2(market, "HOUR", "2");

                                if (response != null)

and the results. only 2 had issues this time, even with 2 second wait. with 1 second I get a lot more.

time: 18/03/2021 11:58:01
time: 18/03/2021 11:59:01
time: 18/03/2021 12:00:01
persist 15: 18/03/2021 12:00:01 - CS.D.AUDUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURCHF.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURGBP.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDCAD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDCHF.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.DOW.DAILY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.NASDAQ.CASH.IP
persist 15: 18/03/2021 12:00:01 - IX.D.SPTRD.DAILY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.DAX.DAILY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.FTSE.DAILY.IP
persist 15: 18/03/2021 12:00:01 - CC.D.DX.USS.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USCSI.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.AUDJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.AUDCHF.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPAUD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPCAD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURCAD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDMXN.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.CADJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.CADCHF.TODAY.IP
response is null for CS.D.EURAUD.TODAY.IP 15
persist 15: 18/03/2021 12:00:01 - CS.D.NZDJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.NZDUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.CHFJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USCGC.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CC.D.CL.USS.IP
persist 15: 18/03/2021 12:00:01 - CS.D.AUDCAD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURGBP.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.GBPUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDCAD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.DOW.DAILY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.NASDAQ.CASH.IP
persist 60: 18/03/2021 12:00:01 - IX.D.SPTRD.DAILY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.DAX.DAILY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.FTSE.DAILY.IP
persist 60: 18/03/2021 12:00:01 - CC.D.DX.USS.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USCSI.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.GBPAUD.TODAY.IP
response is null for CS.D.GBPCAD.TODAY.IP 60
persist 60: 18/03/2021 12:00:01 - CS.D.EURCAD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDMXN.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.GBPJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.CADJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.CADCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURAUD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.NZDJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.NZDUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.CHFJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USCGC.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CC.D.CL.USS.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDCAD.TODAY.IP
time: 18/03/2021 12:03:01

 

Link to comment
  • 0

Thanks for your response, svb. It looks like my problem is indeed an allowance problem but I have been seeing the same intermittent issues as you with various waits/pauses affecting it (I found I needed 2.5 seconds to make a consistent difference).

When I do historical price search from the API companion, all I get back is this: errorCode": "error.public-api.exceeded-account-historical-data-allowance. I can't see that meta data that you reference. Are you able to see this when you use the companion? Are you using a historical price request?

Thanks

Link to comment
  • 0

For what it's worth... I too get forbidden responses from the REST API and I too retry the Price request and then it usually works. In fact, I retry up to 10 times as sometimes it gives me forbidden repeatedly. It can happen getting Navigation Nodes as well as Prices. It isn't allowance and looks to me more like something server-side e.g. bandwidth throttling perhaps? I just retry failed requests in a loop and haven't figured out any proper fix but the retry loop works fine so not a big problem

Link to comment
  • 0

Hello everyone,
I add to the problem, until last week everything was working great. This week the api returns errorCode: null in any type of call. Not only with prices, also obtaining markets, and even opening the session. It seems to me a somewhat dirty solution to retry in all calls, and that increases the operation time of my algorithms, making it unsafe

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • The $CATS airdrop has officially started today, which is great news! Bitget is distributing 30k $CATS to the first 200k users, along with other exciting rewards. To qualify, follow these steps: 1. Open the bot. 2. Select Bitget as the exchange to deposit (it’s listed first). 3. Submit your UID and Cats deposit address. 4. Click send. It's that easy! If you've been farming $CATS, this is a great opportunity to boost your holdings with just a few simple tasks.  
    • The changes around sports betting and online gambling have really opened things up. It’s crazy how much the market is growing, and it’s not just for hardcore gamblers—there’s room for casual players too.
    • Cats and Dogs remain the most influential crypto meme community with every blockchain having its own. Recently, Ton blockchain witness the successful listing of its first Dogs meme which did a massive airdrop to users to the point the airdrop is now the yardstick for measuring successful project on Ton blockchain. Well, many feel the project has full backing from Durov and Musk since they are among the top Dogs meme family in this industry. The launch of Dogs sparks the rise of Cats with many teasing the cats meme community to surpass dogs success. I wonder if this rival could mean anything to TON blockchain but we await the listing price. With CATS about to listed, the project has open deposit so users can choose their respective preferred exchange to trade their token. Currently, only Bitget is available with a 30k $cats airdrop to the first 200k users that deposit while the project team continue working tirelessly to open deposit for the remaining exchanges. I wonder if this will pay for hamsterkombat and catizen failure and list above Dogs FDV.
×
×
  • Create New...
us