{"record":{"id":"bc251106d6ab44fe","repo":"HangfireIO/Hangfire","slug":"servertimeout-must-be-either-non-negative-and-equa","errorCode":null,"errorMessage":"ServerTimeout must be either non-negative and equal to or less than {ServerWatchdog.MaxServerTimeout.Hours} hours","messagePattern":"ServerTimeout 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":163,"sourceCode":"            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            }\n        }\n\n        public TimeSpan CancellationCheckInterval { get; set; }\n\n        [Obsolete(\"Please use `ServerTimeout` or `ServerCheckInterval` options instead. Will be removed in 2.0.0.\")]\n        public ServerWatchdogOptions ServerWatchdogOptions { get; set; }\n\n        [CanBeNull]\n        public IJobFilterProvider FilterProvider { get; set; }\n\n        [CanBeNull]\n        public JobActivator Activator { get; set; }\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/BackgroundJobServerOptions.cs#L145-L181","documentation":"This ArgumentOutOfRangeException(\"value\", \"ServerTimeout must be either non-negative and equal to or less than ServerWatchdog.MaxServerTimeout.Hours hours\") is thrown by the ServerTimeout setter of BackgroundJobServerOptions. The value must be non-negative and not exceed ServerWatchdog.MaxServerTimeout. ServerTimeout defines how long a server can go without a heartbeat before the watchdog considers it dead and removes it.","triggerScenarios":"Assigning a negative ServerTimeout; assigning a value greater than ServerWatchdog.MaxServerTimeout; binding an out-of-range value from configuration.","commonSituations":"Raising ServerTimeout to tolerate slow environments beyond the watchdog ceiling; config typos producing negative values; unit confusion; binding a misconfigured large value.","solutions":["Use a non-negative TimeSpan no greater than ServerWatchdog.MaxServerTimeout (default ServerWatchdog.DefaultServerTimeout).","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.ServerTimeout = TimeSpan.FromHours(48); // exceeds MaxServerTimeout\n\n// after\noptions.ServerTimeout = ServerWatchdog.DefaultServerTimeout; // safe default","handlingStrategy":"validation","validationCode":"TimeSpan Sanitize(TimeSpan ts) =>\n    ts >= TimeSpan.Zero && ts <= ServerWatchdog.MaxServerTimeout ? ts : ServerWatchdog.DefaultServerTimeout;\noptions.ServerTimeout = Sanitize(parsed);","typeGuard":"static bool IsValid(TimeSpan ts) => ts >= TimeSpan.Zero && ts <= ServerWatchdog.MaxServerTimeout;","tryCatchPattern":"try { options.ServerTimeout = parsed; }\ncatch (ArgumentOutOfRangeException) { options.ServerTimeout = ServerWatchdog.DefaultServerTimeout; }","preventionTips":["Cap against ServerWatchdog.MaxServerTimeout.","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"}