OrchardCMS/OrchardCore · error · AntivirusScanningException
The ClamAV antivirus scanner is enabled but the connection…
Error message
The ClamAV antivirus scanner is enabled but the connection timeout must be greater than zero.
What it means
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.
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.
Example fix
// before options.ConnectTimeoutSeconds = 0; // after options.ConnectTimeoutSeconds = 30;
Defensive patterns
Strategy: validation
Validate before calling
if (options.ConnectTimeoutSeconds <= 0)
throw new InvalidOperationException("ClamAV ConnectTimeoutSeconds must be greater than zero."); Try / catch
try
{
await UploadFileAsync(stream);
}
catch (AntivirusScanningException ex) when (ex.Message.Contains("connection timeout"))
{
// fix configuration before accepting uploads
} Prevention
- 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.
When it happens
Trigger: Antivirus feature enabled, file uploaded, and ClamAvOptions.ConnectTimeoutSeconds is 0 (unset default) or negative in configuration.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- The ClamAV antivirus scanner is enabled but the transfer…
- The ClamAV antivirus scanner is enabled but the port…
- The file extension should start with a dot.
- The variable ' ' was used in the recipe but not defined…
- The ClamAV antivirus scanner timed out while scanning
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/4cf4be9f38dafc3d.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore.Modules/OrchardCore.Antivirus/ClamAV/ClamAvFileEventHandler.cs:174
throw new AntivirusScanningException(
$"The ClamAV antivirus scanner returned an unexpected response while scanning '{context.FileName}': {response}");
}
private void ValidateOptions()
{
if (string.IsNullOrWhiteSpace(_options.Host))
{
throw new AntivirusScanningException("The ClamAV antivirus scanner is enabled but the host setting is missing.");
}
if (_options.Port is < 1 or > 65535)
{
throw new AntivirusScanningException("The ClamAV antivirus scanner is enabled but the port setting is invalid.");
}
if (_options.ConnectTimeoutSeconds <= 0)
{
throw new AntivirusScanningException("The ClamAV antivirus scanner is enabled but the connection timeout must be greater than zero.");
}
if (_options.TransferTimeoutSeconds <= 0)
{
throw new AntivirusScanningException("The ClamAV antivirus scanner is enabled but the transfer timeout must be greater than zero.");
}
}
}
View on GitHub (pinned to 4306c0717f)