update messaggi timeout

This commit is contained in:
Samuele Locatelli
2021-09-29 19:05:09 +02:00
parent 89261bd5f8
commit b697e21656
+13 -9
View File
@@ -555,33 +555,37 @@ namespace IOB_WIN_NEXT
// se != null --> uso address...
if (address != null)
{
pingTOut = rand.Next(100, 200);
reply = pingSender.Send(address, pingServerMsTimeout + pingTOut);
pingTOut = rand.Next(200, 400);
reply = pingSender.Send(address, pingTOut);
}
else
{
pingTOut = rand.Next(200, 400);
reply = pingSender.Send(cIobConf.cncIpAddr, pingServerMsTimeout + pingTOut);
pingTOut = rand.Next(300, 600);
reply = pingSender.Send(cIobConf.cncIpAddr, pingTOut);
}
}
catch (Exception exc)
{
pingTOut = rand.Next(50, 100);
reply = pingSender.Send(IPAddress.Loopback, pingServerMsTimeout + pingTOut);
pingTOut = rand.Next(100, 200);
reply = pingSender.Send(IPAddress.Loopback, pingTOut);
lgError($"ping to loopback addres per eccezione:{Environment.NewLine}{exc}");
}
// se ho timeout riprovo...
while (reply.Status != IPStatus.Success && numRetry < maxRetry)
{
lgInfo($"Server Ping KO | reply: {reply.Status} --> retry");
Thread.Sleep(rand.Next(300, 600));
reply = pingSender.Send(address, pingServerMsTimeout * numRetry / 2 + pingTOut);
Thread.Sleep(rand.Next(50, 200));
pingTOut = pingServerMsTimeout * numRetry / 2;
reply = pingSender.Send(address, pingTOut);
numRetry++;
if (reply.Status == IPStatus.Success)
{
lgInfo("Server PING OK!");
break;
}
else
{
lgInfo($"Server Ping KO | reply: {reply.Status} --> retry | TimeOut: {pingTOut}");
}
}
}
answ = reply.Status;