cloudfoundry / cf-java-client

Java Client Library for Cloud Foundry
Apache License 2.0
328 stars 318 forks source link

Handling of expired access tokens when CF CC rate limiting exhausts #960

Open saurav28 opened 5 years ago

saurav28 commented 5 years ago

Hi All,

This issue is same as related to one opened on CF CLI

https://github.com/cloudfoundry/cli/issues/1582

CF CC has a rate limit of unauthenticated calls per IP. In our situation some of the CF applications share the same IP due to NAT.

In case of performing operations with expired access tokens from multiple apps we easily reach the unauthenticated rate limit and CF responds with 429.

I checked the code in AbstractReactorOperations

Token is only refreshed when 401 unauthorised is thrown.

It will be helpful we can check the suggestions mentioned the attached bug.

Please let me know if i am missing something or if the same CLI bug does not apply to CF java client.

Best Regards, Saurav

eaglerainbow commented 4 years ago

I have another case where something similar happens at https://github.com/promregator/promregator/issues/171 . I am currently thinking about implementing a rate limit on application side - which feels more like a workaround. As this is purely in the communication path between CF client and CFCC, I'd appreciate if rate limiting would be done on the libraries side. The latter also has much better access to the X-RateLimit HTTP headers (though I have some doubts - based on observations so far - that these values report the truth).

dmikusa commented 2 years ago

This seems reasonable. I'm acknowledging this as an enhancement request.