timdorr / tesla-api

🚘 A Ruby gem and unofficial documentation of Tesla's JSON API for the Model S, 3, X, and Y.
https://tesla-api.timdorr.com/
MIT License
1.98k stars 532 forks source link

Should `tesla-api` gem provide a default `retry_options`? #753

Closed neomilium closed 10 months ago

neomilium commented 10 months ago

According to my experiments, even with the fix example available at #752 , the code still often fails due to 408 (Request Timeout) HTTP status code.

I was about to provide a fix for the README example in order to use this…

retry_options = {
  max: 3,                   # Retry a failed request up to 3 times
  interval: 2,              # First retry after 2s
  backoff_factor: 2,        # Double the delay for each subsequent retry
  methods: [:post],
  retry_statuses: [408]
}

…but could be better to set it as default options.

Should we show how to use retry_options in example or set a default value in code that makes gem usable out of the box?

timdorr commented 10 months ago

I worry that turning this on by default will cause more folks to get throttled or blocked unintentionally. While it may be OK to handle them with 408s, the Akamai frontend they use is rather wacky in nature and may be using that status code as a test for automated access. It's really hard to know for sure.

I say we leave it blank to default to users not getting blocked. You can always turn it on if you've figured out the right settings that work for you.