SignalR/SignalR · error · ArgumentOutOfRangeException
KeepAlive value must be greater than two seconds.
Error message
KeepAlive value must be greater than two seconds.
What it means
Thrown by DefaultConfigurationManager.KeepAlive setter when the supplied value is below _minimumKeepAlive (two seconds). KeepAlive controls how often the server sends keep-alive pings; a value too small would flood clients with pings, so it is clamped to a safe floor.
Source
Thrown at src/Microsoft.AspNet.SignalR.Core/Configuration/DefaultConfigurationManager.cs:78
throw new InvalidOperationException(Resources.Error_DisconnectTimeoutCannotBeConfiguredAfterKeepAlive);
}
_disconnectTimeout = value;
_keepAlive = TimeSpan.FromTicks(_disconnectTimeout.Ticks / _minimumKeepAlivesPerDisconnectTimeout);
}
}
public TimeSpan? KeepAlive
{
get
{
return _keepAlive;
}
set
{
if (value < _minimumKeepAlive)
{
throw new ArgumentOutOfRangeException("value", Resources.Error_KeepAliveMustBeGreaterThanTwoSeconds);
}
if (value > TimeSpan.FromTicks(_disconnectTimeout.Ticks / _minimumKeepAlivesPerDisconnectTimeout))
{
throw new ArgumentOutOfRangeException("value", Resources.Error_KeepAliveMustBeNoMoreThanAThirdOfTheDisconnectTimeout);
}
_keepAlive = value;
_keepAliveConfigured = true;
}
}
public int DefaultMessageBufferSize
{
get;
set;
}
View on GitHub (pinned to 693053b89a)
Solutions
- Use a KeepAlive of at least two seconds (e.g., TimeSpan.FromSeconds(2) or higher).
- Ensure the value is also no more than a third of DisconnectTimeout.
- Leave KeepAlive at its default if tuning is unnecessary.
Example fix
// before GlobalHost.Configuration.KeepAlive = TimeSpan.FromMilliseconds(500); // after GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(2);
Defensive patterns
Strategy: validation
Validate before calling
var desired = TimeSpan.FromSeconds(keepAliveSeconds);
if (desired >= TimeSpan.FromSeconds(2))
GlobalHost.Configuration.KeepAlive = desired; Type guard
static readonly TimeSpan MinimumKeepAlive = TimeSpan.FromSeconds(2);
Prevention
- Keep KeepAlive >= 2 seconds.
- Validate loaded config values against the floor before applying.
- Prefer the default unless tuning is truly needed.
When it happens
Trigger: Setting GlobalHost.Configuration.KeepAlive to a TimeSpan less than two seconds.
Common situations: Tuning for very low latency or aggressive connection liveness detection; using a sub-two-second value copied from an outdated guide.
Related errors
- KeepAlive value must be no more than a third of the Disconne
- DisconnectTimeout must be at least six seconds.
- DisconnectTimeout cannot be configured after the KeepAlive.
- The value of the MaxScaleoutMappingsPerStream property must
- SignalR: Error loading hubs. Ensure your hubs reference is c
AI-assisted analysis of SignalR/SignalR@693053b89a (2026-08-13).
Data as JSON: /api/errors/9164a76c57404405.
Report an issue: GitHub.