OrchardCMS/OrchardCore · error · AntivirusScanningException

The ClamAV antivirus scanner is enabled but the transfer…

Error message

The ClamAV antivirus scanner is enabled but the transfer timeout must be greater than zero.

What it means

ValidateOptions requires TransferTimeoutSeconds > 0 when ClamAV is enabled. A zero or negative transfer timeout throws this AntivirusScanningException during the first file scan, since stream transfer to clamd must have a positive deadline.

Solutions

  1. Set TransferTimeoutSeconds to a positive value sized for your largest upload (e.g. 300).
  2. Review the full ClamAV options block for unset numeric settings defaulting to 0.
  3. Validate options at startup to fail fast.
  4. If scans are timing out afterward, raise the value rather than disabling it.

Example fix

// before
options.TransferTimeoutSeconds = 0;
// after
options.TransferTimeoutSeconds = 300;
Defensive patterns

Strategy: validation

Validate before calling

if (options.TransferTimeoutSeconds <= 0)
    throw new InvalidOperationException("ClamAV TransferTimeoutSeconds must be greater than zero.");

Try / catch

try
{
    await UploadFileAsync(stream);
}
catch (AntivirusScanningException ex) when (ex.Message.Contains("transfer timeout"))
{
    // fix configuration before accepting uploads
}

Prevention

When it happens

Trigger: Antivirus feature enabled, upload triggers CreatingAsync, and ClamAvOptions.TransferTimeoutSeconds is 0 or negative in configuration.

Common situations: Only Host/Port/ConnectTimeout configured while transfer timeout stays 0, config binding failure, or setting 0 intending 'unlimited'.

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.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/447c930a28be62a7. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Antivirus/ClamAV/ClamAvFileEventHandler.cs:179

    {
        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)