increase max ping

This commit is contained in:
Valentin Balaschenko
2025-04-17 10:54:03 +01:00
parent 4008662fd5
commit cdb9f8c21f
2 changed files with 24 additions and 9 deletions

View File

@@ -57,7 +57,10 @@ namespace {
std::chrono::milliseconds constexpr peerHighLatency{300};
/** How often we PING the peer to check for latency and sendq probe */
std::chrono::seconds constexpr peerTimerInterval{300};
std::chrono::seconds constexpr peerTimerInterval{60};
uint16_t constexpr maxPingNumber = 5;
} // namespace
// TODO: Remove this exclusion once unit tests are added after the hotfix
@@ -730,7 +733,13 @@ PeerImp::onTimer(error_code const& ec)
}
// Already waiting for PONG
if (lastPingSeq_)
if (lastPingSeq_ && (pingAttempts_ < maxPingNumber))
{
pingAttempts_++;
JLOG(journal_.info()) << "Missing PONG, sending PING, attempt "
<< pingAttempts_ << " of " << maxPingNumber;
}
else if (lastPingSeq_)
{
fail("Ping Timeout");
return;
@@ -738,6 +747,7 @@ PeerImp::onTimer(error_code const& ec)
lastPingTime_ = clock_type::now();
lastPingSeq_ = rand_int<std::uint32_t>();
pingAttempts_ = 0;
protocol::TMPing message;
message.set_type(protocol::TMPing::ptPING);
@@ -1105,6 +1115,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMPing> const& m)
if (m->seq() == lastPingSeq_)
{
lastPingSeq_.reset();
pingAttempts_ = 0;
// Update latency estimate
auto const rtt = std::chrono::round<std::chrono::milliseconds>(
@@ -1488,7 +1499,8 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMProofPathRequest> const& m)
}
else
{
peer->send(std::make_shared<Message>(
peer->send(
std::make_shared<Message>(
reply, protocol::mtPROOF_PATH_RESPONSE));
}
}
@@ -1543,7 +1555,8 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMReplayDeltaRequest> const& m)
}
else
{
peer->send(std::make_shared<Message>(
peer->send(
std::make_shared<Message>(
reply, protocol::mtREPLAY_DELTA_RESPONSE));
}
}

View File

@@ -112,6 +112,7 @@ private:
std::optional<std::chrono::milliseconds> latency_;
std::optional<std::uint32_t> lastPingSeq_;
uint16_t pingAttempts_ = 0;
clock_type::time_point lastPingTime_;
clock_type::time_point const creationTime_;
@@ -715,7 +716,8 @@ PeerImp::PeerImp(
app_.config().LEDGER_REPLAY))
, ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
{
read_buffer_.commit(boost::asio::buffer_copy(
read_buffer_.commit(
boost::asio::buffer_copy(
read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
JLOG(journal_.info()) << "compression enabled "
<< (compressionEnabled_ == Compressed::On)