Consent freshness delay after first try failed
The issue lies in that the consent freshness delay is calculated correctly for the first time as
agent/conncheck.c:priv_conn_keepalive_tick_unlocked
---
/* random range over 0.8 -> 1.2 as specified in RFC7675 */
double modifier = g_random_double() * 0.4 + 0.8;
guint64 delay = 1000 * MAX((guint64) ((NICE_AGENT_TIMER_CONSENT_DEFAULT) * modifier),
NICE_AGENT_TIMER_MIN_CONSENT_INTERVAL);
but in case if it fails the next delay will be incorrectly set to the leftover of consent timeout in priv_conn_remote_consent_tick_agent_locked. I copy pasted that first delay calculation in that second spot and it fixed my reconnection issue due to concent freshness checks started to perform as described in rfc.
Following is a diff for the solution to wrong delays.
diff --git a/agent/conncheck.c b/agent/conncheck.c
index 4b45080..68d616d 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -1282,7 +1282,9 @@ static gboolean priv_conn_remote_consent_tick_agent_locked (
agent_signal_component_state_change (agent, pair->keepalive.stream_id,
pair->keepalive.component_id, NICE_COMPONENT_STATE_FAILED);
} else {
- guint64 delay = (consent_timeout - (now - pair->remote_consent.last_received)) / 1000;
+ double modifier = g_random_double() * 0.4 + 0.8;
+ guint64 delay = MAX((guint64) ((NICE_AGENT_TIMER_CONSENT_DEFAULT) * modifier),
+ NICE_AGENT_TIMER_MIN_CONSENT_INTERVAL);
nice_debug ("Agent %p : pair %p rechecking consent in %" G_GUINT64_FORMAT ".%03" G_GUINT64_FORMAT "s",
agent, pair, delay / 1000, delay % 1000);
agent_timeout_add_with_context (agent,