Skip to content

Commit a5370f7

Browse files
authored
Merge pull request #8097 from Icinga/bugfix/don-not-close-connection-on-missing-heartbeat-8095
Don't close connection on missing heartbeat
2 parents a5d4b57 + a0a5348 commit a5370f7

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

lib/remote/jsonrpcconnection-heartbeat.cpp

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ using namespace icinga;
1515

1616
REGISTER_APIFUNCTION(Heartbeat, event, &JsonRpcConnection::HeartbeatAPIHandler);
1717

18+
/**
19+
* We still send a heartbeat without timeout here
20+
* to keep the m_Seen variable up to date. This is to keep the
21+
* cluster connection alive when there isn't much going on.
22+
*/
23+
1824
void JsonRpcConnection::HandleAndWriteHeartbeats(boost::asio::yield_context yc)
1925
{
2026
boost::system::error_code ec;
@@ -27,41 +33,16 @@ void JsonRpcConnection::HandleAndWriteHeartbeats(boost::asio::yield_context yc)
2733
break;
2834
}
2935

30-
if (m_NextHeartbeat != 0 && m_NextHeartbeat < Utility::GetTime()) {
31-
{
32-
Log logMsg (LogWarning, "JsonRpcConnection");
33-
34-
if (m_Endpoint) {
35-
logMsg << "Client for endpoint '" << m_Endpoint->GetName() << "'";
36-
} else {
37-
logMsg << "Anonymous client";
38-
}
39-
40-
logMsg << " has requested heartbeat message but hasn't responded in time. Closing connection.";
41-
}
42-
43-
Disconnect();
44-
break;
45-
}
46-
4736
SendMessageInternal(new Dictionary({
4837
{ "jsonrpc", "2.0" },
4938
{ "method", "event::Heartbeat" },
50-
{ "params", new Dictionary({
51-
{ "timeout", 120 }
52-
}) }
39+
{ "params", new Dictionary() }
5340
}));
5441
}
5542
}
5643

5744
Value JsonRpcConnection::HeartbeatAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
5845
{
59-
Value vtimeout = params->Get("timeout");
60-
61-
if (!vtimeout.IsEmpty()) {
62-
origin->FromClient->m_NextHeartbeat = Utility::GetTime() + vtimeout;
63-
}
64-
6546
return Empty;
6647
}
6748

0 commit comments

Comments
 (0)