mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-30 15:22:03 +08:00
HTTP: changed retry strategy so the max period is ~4mins and limited to 16 retries
This commit is contained in:
parent
ebca3d29f2
commit
b5c97738be
@ -752,7 +752,9 @@ wxString ConnectWebViewPanel::get_login_script(bool refresh)
|
||||
|
||||
let retry = false;
|
||||
let backoff = 1000;
|
||||
const maxBackoff = 64000;
|
||||
const maxBackoff = 64000 * 4;
|
||||
const maxRetries = 16;
|
||||
let numRetries = 0;
|
||||
do {
|
||||
|
||||
let error = false;
|
||||
@ -763,7 +765,8 @@ wxString ConnectWebViewPanel::get_login_script(bool refresh)
|
||||
let body = await resp.text();
|
||||
_prusaSlicer_log('Slicer Login resp ' + resp.status + ' (' + token.substring(token.length - 8) + ') body: ' + body);
|
||||
if (resp.status >= 500 || resp.status == 408) {
|
||||
retry = true;
|
||||
numRetries++;
|
||||
retry = maxRetries <= 0 || numRetries <= maxRetries;
|
||||
} else {
|
||||
retry = false;
|
||||
if (resp.status >= 400)
|
||||
@ -772,6 +775,7 @@ wxString ConnectWebViewPanel::get_login_script(bool refresh)
|
||||
} catch (e) {
|
||||
_prusaSlicer_log('Slicer Login failed: ' + e.toString());
|
||||
console.error('Slicer Login failed', e.toString());
|
||||
// intentionally not taking care about max retry count, as this is not server error but likely being offline
|
||||
retry = true;
|
||||
}
|
||||
|
||||
|
@ -464,7 +464,7 @@ Http::Http(const std::string &url) : p(new priv(url)) {}
|
||||
const HttpRetryOpt& HttpRetryOpt::default_retry()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
static HttpRetryOpt val = {500ms, 64s, 0};
|
||||
static HttpRetryOpt val = {500ms, std::chrono::milliseconds(MAX_RETRY_DELAY_MS), MAX_RETRIES};
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,9 @@ struct HttpRetryOpt
|
||||
|
||||
static const HttpRetryOpt& no_retry();
|
||||
static const HttpRetryOpt& default_retry();
|
||||
|
||||
static constexpr size_t MAX_RETRY_DELAY_MS = 4 * 64000;
|
||||
static constexpr size_t MAX_RETRIES = 16;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user