Randomize interval between connection retries
Add a random delay between 1 and 15 secs
This commit is contained in:
parent
7204e56259
commit
e2c6c85767
@ -65,10 +65,10 @@ bool checkPoolConnection(void) {
|
|||||||
WiFi.hostByName(poolString, serverIP);
|
WiFi.hostByName(poolString, serverIP);
|
||||||
Serial.printf("Resolved DNS got: %s\n", serverIP.toString());
|
Serial.printf("Resolved DNS got: %s\n", serverIP.toString());
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Implements a socketKeepAlive function and
|
//Implements a socketKeepAlive function and
|
||||||
@ -144,8 +144,10 @@ void runStratumWorker(void *name) {
|
|||||||
//strcpy(btcString,"test");
|
//strcpy(btcString,"test");
|
||||||
|
|
||||||
if(!checkPoolConnection())
|
if(!checkPoolConnection())
|
||||||
//If server not reachable add 5sec delay bettween connection petitions
|
//If server is not reachable add random delay for connection retries
|
||||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
srand(millis());
|
||||||
|
//Generate value between 1 and 15 secs
|
||||||
|
vTaskDelay(((1 + rand() % 15) * 1000) / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
if(!isMinerSuscribed){
|
if(!isMinerSuscribed){
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user