Browse Source

fix connection error - retry now with max 10

connection-errors
Deniod 7 months ago
parent
commit
8efc8fdfff
  1. 2
      lib/Cargo.lock
  2. 2
      lib/Cargo.toml
  3. 18
      src/controller.cpp

2
lib/Cargo.lock

@ -1849,7 +1849,7 @@ dependencies = [
[[package]]
name = "silentdragonlitelib"
version = "0.1.0"
source = "git+https://git.hush.is/lucretius/silentdragonlite-cli?rev=eff5dd7b6dbcfd7e4db6fdba423399337b590722#eff5dd7b6dbcfd7e4db6fdba423399337b590722"
source = "git+https://git.hush.is/lucretius/silentdragonlite-cli?rev=a79e93ed7a6389ee0990e0c1f48f8ada84be41d6#a79e93ed7a6389ee0990e0c1f48f8ada84be41d6"
dependencies = [
"base58",
"bellman",

2
lib/Cargo.toml

@ -12,4 +12,4 @@ crate-type = ["staticlib"]
libc = "0.2.58"
lazy_static = "1.4.0"
blake3 = "0.3.4"
silentdragonlitelib = { git = "https://git.hush.is/lucretius/silentdragonlite-cli", rev = "eff5dd7b6dbcfd7e4db6fdba423399337b590722" }
silentdragonlitelib = { git = "https://git.hush.is/lucretius/silentdragonlite-cli", rev = "a79e93ed7a6389ee0990e0c1f48f8ada84be41d6" }

18
src/controller.cpp

@ -10,6 +10,8 @@
#include "websockets.h"
#include "Model/ChatItem.h"
#include "DataStore/DataStore.h"
#include <thread>
ChatModel *chatModel = new ChatModel();
Chat *chat = new Chat();
@ -302,9 +304,19 @@ void Controller::processInfo(const json& info)
void Controller::getInfoThenRefresh(bool force)
{
qDebug()<< __func__;
if (!zrpc->haveConnection())
return noConnection();
qDebug()<< __func__;
int attempts = 0;
int max_attempts = 10;
while (!zrpc->haveConnection()) {
if (attempts >= max_attempts) {
return noConnection();
}
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts));
attempts++;
}
static bool prevCallSucceeded = false;

Loading…
Cancel
Save