OrchardCMS/OrchardCore · error · AntivirusScanningException
The ClamAV antivirus scanner failed while scanning
Error message
The ClamAV antivirus scanner failed while scanning '{context.FileName}'. What it means
IOException during the ClamAV INSTREAM scan is caught in CreatingAsync and rethrown as an AntivirusScanningException with this generic failure message. It indicates a stream/IO failure while transferring the file to or reading the result from the ClamAV daemon.
Solutions
- Inspect the inner exception (logged via LogError) to find the underlying IO cause.
- Check clamd's StreamMaxLength / TCPSocket settings — oversized streams can be dropped.
- Ensure clamd is stable (uptime, memory) and not being restarted mid-upload.
- Retry the upload; if persistent, check disk space and temp directory health on the app host.
Defensive patterns
Strategy: retry
Try / catch
try
{
await UploadFileAsync(stream);
}
catch (AntivirusScanningException ex) when (ex.InnerException is IOException)
{
logger.LogError(ex, "IO failure during AV scan; retrying may help.");
// retry once, then fail the upload cleanly
} Prevention
- Set clamd StreamMaxLength above the app's max upload size.
- Monitor clamd restarts and connection resets.
- Keep adequate disk space for temp seekable streams.
- Avoid proxies/load balancers in the clamd socket path.
When it happens
Trigger: ScanAsync raises IOException — e.g. the clamd connection drops mid-transfer, the temp seekable stream write/read fails, or the socket stream is broken while scanning context.FileName.
Common situations: clamd restarting mid-scan, connection reset by clamd's StreamMaxLength limit, disk issues with the temp file, flaky network between app and daemon.
Related errors
- The ClamAV antivirus scanner timed out while scanning
- Cannot create a stream for a directory.
- Error retrieving file info for
- Error creating directory
- Error deleting file
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/f4b93f6d01168137.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore.Modules/OrchardCore.Antivirus/ClamAV/ClamAvFileEventHandler.cs:88
if (scanStream != stream)
{
await scanStream.DisposeAsync();
}
_logger.LogError(exception, "ClamAV could not be reached while scanning '{FileName}'.", context.FileName);
throw new AntivirusScanningException($"The ClamAV antivirus scanner could not be reached while scanning '{context.FileName}'.", exception);
}
catch (IOException exception)
{
if (scanStream != stream)
{
await scanStream.DisposeAsync();
}
_logger.LogError(exception, "ClamAV failed while scanning '{FileName}'.", context.FileName);
throw new AntivirusScanningException($"The ClamAV antivirus scanner failed while scanning '{context.FileName}'.", exception);
}
catch
{
if (scanStream != stream)
{
await scanStream.DisposeAsync();
}
throw;
}
}
public Task CreatedAsync(IFileStoreEntry fileInfo, CancellationToken cancellationToken = default)
=> Task.CompletedTask;
private async Task<Stream> CreateSeekableStreamAsync(Stream stream, CancellationToken cancellationToken)
{
var tempFilePath = _tempDirectoryProvider.GetTempFileName();View on GitHub (pinned to 4306c0717f)