{"record":{"id":"0cb058d8e3af8f07","repo":"HangfireIO/Hangfire","slug":"servercheckinterval-must-be-either-non-negative-an","errorCode":null,"errorMessage":"ServerCheckInterval must be either non-negative and equal to or less than {ServerWatchdog.MaxServerCheckInterval.Hours} hours","messagePattern":"ServerCheckInterval must be either non-negative and equal to or less than (.+?) hours","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/BackgroundJobServerOptions.cs","lineNumber":150,"sourceCode":"            get { return _heartbeatInterval; }\n            set\n            {\n                if (value < TimeSpan.Zero || value > ServerWatchdog.MaxHeartbeatInterval)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"HeartbeatInterval must be either non-negative and equal to or less than {ServerWatchdog.MaxHeartbeatInterval.Hours} hours\");\n                }\n                _heartbeatInterval = value;\n            }\n        }\n\n        public TimeSpan ServerCheckInterval\n        {\n            get { return _serverCheckInterval; }\n            set\n            {\n                if (value < TimeSpan.Zero || value > ServerWatchdog.MaxServerCheckInterval)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"ServerCheckInterval must be either non-negative and equal to or less than {ServerWatchdog.MaxServerCheckInterval.Hours} hours\");\n                }\n                _serverCheckInterval = value;\n            }\n        }\n\n        public TimeSpan ServerTimeout\n        {\n            get { return _serverTimeout; }\n            set\n            {\n                if (value < TimeSpan.Zero || value > ServerWatchdog.MaxServerTimeout)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), $\"ServerTimeout must be either non-negative and equal to or less than {ServerWatchdog.MaxServerTimeout.Hours} hours\");\n                }\n\n                _serverTimeout = value;\n\n            }","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/BackgroundJobServerOptions.cs#L132-L168","documentation":"This ArgumentOutOfRangeException(\"value\", \"ServerCheckInterval must be either non-negative and equal to or less than ServerWatchdog.MaxServerCheckInterval.Hours hours\") is thrown by the ServerCheckInterval setter of BackgroundJobServerOptions. The value must be non-negative and not exceed ServerWatchdog.MaxServerCheckInterval. ServerCheckInterval controls how often the watchdog itself scans for dead servers.","triggerScenarios":"Assigning a negative ServerCheckInterval; assigning a value greater than ServerWatchdog.MaxServerCheckInterval; binding an out-of-range value from configuration.","commonSituations":"Tuning watchdog behavior and exceeding the allowed maximum; config typos; unit confusion; binding a huge value from a misconfigured section.","solutions":["Use a non-negative TimeSpan no greater than ServerWatchdog.MaxServerCheckInterval (default ServerWatchdog.DefaultCheckInterval).","Clamp the bound value into the legal range.","Leave the property unset to keep the default.","Validate the configured value at startup."],"exampleFix":"// before\noptions.ServerCheckInterval = TimeSpan.FromHours(10); // exceeds MaxServerCheckInterval\n\n// after\noptions.ServerCheckInterval = ServerWatchdog.DefaultCheckInterval; // safe default","handlingStrategy":"validation","validationCode":"TimeSpan Sanitize(TimeSpan ts) =>\n    ts >= TimeSpan.Zero && ts <= ServerWatchdog.MaxServerCheckInterval ? ts : ServerWatchdog.DefaultCheckInterval;\noptions.ServerCheckInterval = Sanitize(parsed);","typeGuard":"static bool IsValid(TimeSpan ts) => ts >= TimeSpan.Zero && ts <= ServerWatchdog.MaxServerCheckInterval;","tryCatchPattern":"try { options.ServerCheckInterval = parsed; }\ncatch (ArgumentOutOfRangeException) { options.ServerCheckInterval = ServerWatchdog.DefaultCheckInterval; }","preventionTips":["Cap against ServerWatchdog.MaxServerCheckInterval.","Validate config.","Leave unset for the default."],"tags":["csharp","hangfire","argumentoutofrangeexception","configuration","watchdog","validation","background-jobs"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}