ENH: set timeout to 15 for get version and get plugin

when a DNS problem occurs, the UI isblocked for too long

Change-Id: I3ee1fe1ddb1bec38be9fc3c3e5c3e08931b6eb76
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2022-11-01 15:37:02 +08:00 committed by Lane.Wei
parent 1eacc5d38f
commit 7f53455105
2 changed files with 7 additions and 2 deletions

View file

@ -1303,7 +1303,9 @@ int GUI_App::download_plugin(InstallProgressFn pro_fn, WasCancelledFn cancel_fn)
std::string download_url;
Slic3r::Http http_url = Slic3r::Http::get(url);
BOOST_LOG_TRIVIAL(info) << "[download_plugin]: check the plugin from " << url;
http_url.on_complete(
http_url.timeout_connect(TIMEOUT_CONNECT)
.timeout_max(TIMEOUT_RESPONSE)
.on_complete(
[&download_url](std::string body, unsigned status) {
try {
json j = json::parse(body);
@ -3578,7 +3580,8 @@ void GUI_App::check_new_version(bool show_tips, int by_user)
Slic3r::Http http = Slic3r::Http::get(url);
http.header("accept", "application/json")
.timeout_max(10)
.timeout_connect(TIMEOUT_CONNECT)
.timeout_max(TIMEOUT_RESPONSE)
.on_complete([this, show_tips, by_user](std::string body, unsigned) {
try {
json j = json::parse(body);

View file

@ -28,6 +28,8 @@
#define BBL_HAS_FIRST_PAGE 1
#define STUDIO_INACTIVE_TIMEOUT 15*60*1000
#define LOG_FILES_MAX_NUM 30
#define TIMEOUT_CONNECT 15
#define TIMEOUT_RESPONSE 15
class wxMenuItem;
class wxMenuBar;