{"record":{"id":"4cf4be9f38dafc3d","repo":"OrchardCMS/OrchardCore","slug":"the-clamav-antivirus-scanner-is-enabled-but-the-connection","errorCode":null,"errorMessage":"The ClamAV antivirus scanner is enabled but the connection timeout must be greater than zero.","messagePattern":"The ClamAV antivirus scanner is enabled but the connection timeout must be greater than zero\\.","errorType":"exception","errorClass":"AntivirusScanningException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Antivirus/ClamAV/ClamAvFileEventHandler.cs","lineNumber":174,"sourceCode":"        throw new AntivirusScanningException(\n            $\"The ClamAV antivirus scanner returned an unexpected response while scanning '{context.FileName}': {response}\");\n    }\n\n    private void ValidateOptions()\n    {\n        if (string.IsNullOrWhiteSpace(_options.Host))\n        {\n            throw new AntivirusScanningException(\"The ClamAV antivirus scanner is enabled but the host setting is missing.\");\n        }\n\n        if (_options.Port is < 1 or > 65535)\n        {\n            throw new AntivirusScanningException(\"The ClamAV antivirus scanner is enabled but the port setting is invalid.\");\n        }\n\n        if (_options.ConnectTimeoutSeconds <= 0)\n        {\n            throw new AntivirusScanningException(\"The ClamAV antivirus scanner is enabled but the connection timeout must be greater than zero.\");\n        }\n\n        if (_options.TransferTimeoutSeconds <= 0)\n        {\n            throw new AntivirusScanningException(\"The ClamAV antivirus scanner is enabled but the transfer timeout must be greater than zero.\");\n        }\n    }\n}\n","sourceCodeStart":156,"sourceCodeEnd":183,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Antivirus/ClamAV/ClamAvFileEventHandler.cs#L156-L183","documentation":"ValidateOptions requires ConnectTimeoutSeconds > 0 when ClamAV is enabled. A non-positive value throws this AntivirusScanningException on the first scanned upload, since a zero/negative connect timeout is meaningless for the TCP connection.","triggerScenarios":"Antivirus feature enabled, file uploaded, and ClamAvOptions.ConnectTimeoutSeconds is 0 (unset default) or negative in configuration.","commonSituations":"Configuring only Host/Port and assuming timeouts have sane defaults, a binding failure leaving 0, or someone setting 0 to mean 'no timeout' when >0 is required.","solutions":["Set ConnectTimeoutSeconds to a positive value, e.g. 30.","Audit the ClamAV options block for omitted numeric fields binding to 0.","Validate options at startup so misconfiguration surfaces before uploads.","Document required options in your deployment config templates."],"exampleFix":"// before\noptions.ConnectTimeoutSeconds = 0;\n// after\noptions.ConnectTimeoutSeconds = 30;","handlingStrategy":"validation","validationCode":"if (options.ConnectTimeoutSeconds <= 0)\n    throw new InvalidOperationException(\"ClamAV ConnectTimeoutSeconds must be greater than zero.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await UploadFileAsync(stream);\n}\ncatch (AntivirusScanningException ex) when (ex.Message.Contains(\"connection timeout\"))\n{\n    // fix configuration before accepting uploads\n}","preventionTips":["Set all ClamAV timeout options explicitly in every environment.","Use IValidateOptions/ValidateOnStart to fail fast.","Never use 0 to mean 'infinite' — the validator requires > 0."],"tags":["clamav","configuration","timeout","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}