Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Retrier - limit number of retries #1672

Closed
Footjy opened this issue Oct 6, 2016 · 3 comments
Closed

Request Retrier - limit number of retries #1672

Footjy opened this issue Oct 6, 2016 · 3 comments
Assignees
Milestone

Comments

@Footjy
Copy link

Footjy commented Oct 6, 2016

Hi,

I've been working with the request retrier to reauthenticate when the request fails due to an expired token.

Is there a way to limit the number of retries ? This would be needed in case of a server bug that would send the expired token error when that's not the problem. There we have an infinite loop.

There may be other cases where this is needed.

I've seen this question unanswered on SO so I guess/hope I'm not the only one needing this. If you have some alternative way of doing this, please let me know.

Thanks,

cnoon added a commit that referenced this issue Oct 8, 2016
…rier.

By adding the retryCount to the Request, the RequestRetrier protocol can use the retryCount to determine whether to continue to retry the Request.
cnoon added a commit that referenced this issue Oct 8, 2016
…rier.

By adding the retryCount to the Request, the RequestRetrier protocol can use the retryCount to determine whether to continue to retry the Request.
@cnoon
Copy link
Member

cnoon commented Oct 8, 2016

Hi @Footjy,

There are all sorts of ways you could handle this. I'd start simple and write some check in your RequestRetrier that doesn't allow you to run more than say 3 refreshes within a 10 second timeframe. If you do, then stop retrying the request.

Once you get this check in place, you can slowly modify it over time to be more and more robust. If you post a link to the SO question I'd be happy to answer it there as well.

I also just pushed up PR #1681 which adds a retryCount property to a Request which would allow you to stop retrying a Request after it had been tried once or twice. These options should be more than enough to get you going.

If you have other ideas, please don't hesitate to post them. This system is brand new so we don't know all the ways everyone will be using it.

Cheers. 🍻

@cnoon cnoon closed this as completed Oct 8, 2016
@cnoon cnoon self-assigned this Oct 8, 2016
@cnoon cnoon added this to the 4.1.0 milestone Oct 8, 2016
@Footjy
Copy link
Author

Footjy commented Oct 9, 2016

Hi @cnoon,

Thanks for your answer! The recent pull request was exactly what I was hoping, this is the simplest way to achieve that. And I could indeed have thought about a timer to do that.

Here is the SO question. I'll let you post the answer :)

Cheers.

cnoon added a commit that referenced this issue Oct 10, 2016
…rier.

By adding the retryCount to the Request, the RequestRetrier protocol can use the retryCount to determine whether to continue to retry the Request.
bdonkey added a commit to bdonkey/Alamofire that referenced this issue Oct 23, 2016
* 'master' of github.com:Alamofire/Alamofire: (26 commits)
  [Issue Alamofire#1672] Added Request retryCount property to support RequestRetrier.
  Fixed test target compiler warning by not requiring app extension APIs only.
  [PR Alamofire#1670] Fixed compiler issue with DownloadRequest in AF4 migration guide.
  SPM package file now excludes tests since current configuration is not supported.
  Pulled in the release notes for the 3.5.1 release into the CHANGELOG.
  Added docstrings and note to README about resumeData and background sessions.
  Add 10.12 check for tests results, as macOS results are now correct.
  Added missing dashes in CHANGELOG…no functional changes.
  [PR Alamofire#1633] Fixed sample code in the README where error was used incorrectly.
  [PR Alamofire#1625] Fixed Session Manager internal links in the README.
  [PR Alamofire#1615] Fixed compiler error in response validation sample code in README.
  Added release notes to the CHANGELOG and bumped the version to 4.0.1.
  Removed excess whitespace from some of the docstrings…no functional changes.
  Removed framework and test target overrides that duplicated project settings.
  [PR Alamofire#1612] Fixed compilation issue in response handler section of the README.
  Fixed up if statement formatting…no functional changes.
  Added test verifying download request can be resumed with resume data.
  [Issue Alamofire#1551] Fixed retain cycle when using Validation clsoures.
  Fixed alignment in Travis yaml file…no functional changes.
  [PR Alamofire#1520] Renamed OSX to macOS throughout the project.
  ...
bdonkey added a commit to bdonkey/Alamofire that referenced this issue Nov 1, 2016
* 'master' of github.com:Alamofire/Alamofire: (27 commits)
  [PR Alamofire#1721] Improve embedded framework installation instructions.
  [PR Alamofire#1722] Update README for proper error checking in download.
  [Issue Alamofire#1672] Added Request retryCount property to support RequestRetrier.
  Fixed test target compiler warning by not requiring app extension APIs only.
  [PR Alamofire#1670] Fixed compiler issue with DownloadRequest in AF4 migration guide.
  SPM package file now excludes tests since current configuration is not supported.
  Pulled in the release notes for the 3.5.1 release into the CHANGELOG.
  Added docstrings and note to README about resumeData and background sessions.
  Add 10.12 check for tests results, as macOS results are now correct.
  Added missing dashes in CHANGELOG…no functional changes.
  [PR Alamofire#1633] Fixed sample code in the README where error was used incorrectly.
  [PR Alamofire#1625] Fixed Session Manager internal links in the README.
  [PR Alamofire#1615] Fixed compiler error in response validation sample code in README.
  Added release notes to the CHANGELOG and bumped the version to 4.0.1.
  Removed excess whitespace from some of the docstrings…no functional changes.
  Removed framework and test target overrides that duplicated project settings.
  [PR Alamofire#1612] Fixed compilation issue in response handler section of the README.
  Fixed up if statement formatting…no functional changes.
  Added test verifying download request can be resumed with resume data.
  [Issue Alamofire#1551] Fixed retain cycle when using Validation clsoures.
  ...
@Eash
Copy link

Eash commented Nov 23, 2018

Hi cnoon,
I am working with request retrier for reauthentication of expired token. When token get expired from retrier delegate "should" method, I am getting new token.

But after getting new token it get exit in delegate, request is not continuing and I am not getting any response. So please let me know, where I am wrong.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants