Https calls are not connecting to server

前端 未结 2 1306
情话喂你
情话喂你 2021-01-20 08:38

I am working on Windows Service in visual studio 2017. In the rest api\'s call, getting exceptions while debugging code. Sometimes first 2 3 calls working after

相关标签:
2条回答
  • 2021-01-20 08:41

    Response http code 429 indicates that you sending too many requests on target web service.

    This means service you trying to send requests has a policies that blocks some requests by request-per-time limit.

    Also I admit that external service can be manually configured to throw 403 code in specific cases that you can't know about. If that, this information can be explained in external service documentation... or not :)

    What you can do with this?

    Fit in limitations
    You can make detailed research what limits target webservice has and set up your code to fit in this limitations. For example if service has limitation for receiving only one request per 10 minutes - you must set up your timer to send one request each 10 or more minutes. If documentation not provide such information - you can test it manually by finding some patterns with external service responses.

    Use proxy
    Every limitation policy based on information about requests senders. Usually this information consists of IP address of sender only. This means if you send 2 requests from two different IP addresses - limitation policy will perceive that like 2 different computers sending these requests. So you can find/buy/rent some proxy IP addresses and send requests through there on target web server.

    How to connect through proxy in C# using WebRequest you can see in this answer.

    Negotiate with external service provider
    If you have possibility to communicate with external service developers or help center, you can ask their to reduce limitations for your IP address (if it static) or provide some mechanisms to avoid limitation policy for you. If for some reason they cannot provide this opportunity, at least you can ask detailed information about limitations.

    Repetition mechanism
    Some times 503 error code that is outer exception you received may be caused by service unavailable. It means that server can be under maintenance or temporary overloaded. So you can write repetition mechanism to make continious sending requests to server until it'll be accessible.

    Polly library may help you with repetition mechanism creation

    0 讨论(0)
  • 2021-01-20 08:51

    The inner error of that 503 is:

    The remote server returned an error: (429)

    HTTP 429 indicates too many requests. Maybe your upstream server can’t process all requests sent.

    This can happen when you reached rate limiting / throttling value if you’re calling a third party API.

    UPDATE

    As per page 28 in the API docs, you could configure throttling when creating a new API. Check if the throttling is too small or maybe turn off the throttling and see if that could fix the error?

    0 讨论(0)
提交回复
热议问题