mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8142 from Icinga/bugfix/don-not-close-connection-on-missing-heartbeat-8095
Remove all codes related to the heartbeat timeout
This commit is contained in:
commit
a615b2126e
|
@ -15,6 +15,12 @@ using namespace icinga;
|
||||||
|
|
||||||
REGISTER_APIFUNCTION(Heartbeat, event, &JsonRpcConnection::HeartbeatAPIHandler);
|
REGISTER_APIFUNCTION(Heartbeat, event, &JsonRpcConnection::HeartbeatAPIHandler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We still send a heartbeat without timeout here
|
||||||
|
* to keep the m_Seen variable up to date. This is to keep the
|
||||||
|
* cluster connection alive when there isn't much going on.
|
||||||
|
*/
|
||||||
|
|
||||||
void JsonRpcConnection::HandleAndWriteHeartbeats(boost::asio::yield_context yc)
|
void JsonRpcConnection::HandleAndWriteHeartbeats(boost::asio::yield_context yc)
|
||||||
{
|
{
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
|
@ -27,43 +33,16 @@ void JsonRpcConnection::HandleAndWriteHeartbeats(boost::asio::yield_context yc)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_NextHeartbeat != 0 && m_NextHeartbeat < Utility::GetTime()) {
|
SendMessageInternal(new Dictionary({
|
||||||
{
|
{ "jsonrpc", "2.0" },
|
||||||
Log logMsg (LogWarning, "JsonRpcConnection");
|
{ "method", "event::Heartbeat" },
|
||||||
|
{ "params", new Dictionary() }
|
||||||
if (m_Endpoint) {
|
}));
|
||||||
logMsg << "Client for endpoint '" << m_Endpoint->GetName() << "'";
|
|
||||||
} else {
|
|
||||||
logMsg << "Anonymous client";
|
|
||||||
}
|
|
||||||
|
|
||||||
logMsg << " has requested heartbeat message but hasn't responded in time. Closing connection.";
|
|
||||||
}
|
|
||||||
|
|
||||||
Disconnect();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Endpoint) {
|
|
||||||
SendMessageInternal(new Dictionary({
|
|
||||||
{ "jsonrpc", "2.0" },
|
|
||||||
{ "method", "event::Heartbeat" },
|
|
||||||
{ "params", new Dictionary({
|
|
||||||
{ "timeout", 120 }
|
|
||||||
}) }
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Value JsonRpcConnection::HeartbeatAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
|
Value JsonRpcConnection::HeartbeatAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
|
||||||
{
|
{
|
||||||
Value vtimeout = params->Get("timeout");
|
|
||||||
|
|
||||||
if (!vtimeout.IsEmpty()) {
|
|
||||||
origin->FromClient->m_NextHeartbeat = Utility::GetTime() + vtimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Empty;
|
return Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue