ClamAV Deamon (Socket) - stream_socket_client(): unable to connect to unix: clamd.ctl (Resource temporarily unavailable)

Hi,

Nextcloud version: 12.0.2
Operating system and version: Ubuntu 16.04.3 LTS
Apache or nginx: nginx/1.13.0
PHP version: PHP 7.1.8

Is this the first time you’ve seen this error?: no, happened once before

Can you reliably replicate it? no

The issue you are facing:

My Nextcloud server is using the ClamAV Antivirus App running as Deamon (Socket). The setup followed the setup here: https://docs.nextcloud.com/server/12/admin_manual/configuration_server/antivirus_configuration.html

When one of my users uploaded a file yesterday night, the server got caught in a loop, producing the following error msgs:

Error files_antivirus OCA\Files_Antivirus\BackgroundScanner::run, exception: Cannot connect to “/var/run/clamav/clamd.ctl”: Resource temporarily unavailable (code 11)

Error PHP stream_socket_client(): unable to connect to unix:///var/run/clamav/clamd.ctl (Resource temporarily unavailable) at /var/www/nextcloud/apps/files_antivirus/lib/Scanner/External.php#29

The server is throwing these error msgs at maximum CPU-capacity, so that it is fully occupied and not accessible anymore (also not via ssh). Hard-reboot was my only option to terminate it.

I am not sure if it is really connected to the file uploads, but the the nginx error.log (see below) suggests it.


The output of my config.php:
<?php
$CONFIG = array (
‘instanceid’ => ‘xxxx’,
‘passwordsalt’ => ‘xxxx’,
‘secret’ => ‘xxxx’,
‘trusted_domains’ =>
array (
0 => ‘xxxx’,
1 => ‘xxxx’,
),
‘datadirectory’ => ‘/nc_data’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘12.0.2.0.’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => ‘nextcloud’,
‘dbpassword’ => ‘nextcloud’,
‘mysql.utf8mb4’ => true,
‘htaccess.RewriteBase’ => ‘/’,
‘overwrite.cli.url’ => ‘/’,
‘overwriteprotocol’ => ‘https’,
‘loglevel’ => 2,
‘logtimezone’ => ‘Europe/Berlin’,
‘logfile’ => ‘/var/nc_data/nextcloud.log’,
‘log_rotate_size’ => 104857600,
‘cron_log’ => false,
‘installed’ => true,
‘filesystem_check_changes’ => 1,
‘quota_include_external_storage’ => false,
‘knowledgebaseenabled’ => false,
‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘filelocking.enabled’ => ‘true’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘/var/run/redis/redis.sock’,
‘port’ => 0,
‘timeout’ => 0.0,
),
‘maintenance’ => false,
‘theme’ => ‘’,
‘integrity.check.disabled’ => false,
‘updater.release.channel’ => ‘stable’,
‘enable_previews’ => true,
‘mail_smtpmode’ => ‘smtp’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_smtphost’ => ‘mail.xxx.xx’,
‘mail_smtpport’ => ‘xxxx’,
‘mail_smtpsecure’ => ‘ssl’,
‘mail_from_address’ => ‘xxxx’,
‘mail_domain’ => 'xxxx,
‘mail_smtpauth’ => 1,
‘mail_smtpname’ => ‘xxxx’,
‘mail_smtppassword’ => ‘xxxx’,
);


The output of my nginx error log in /var/log/nginx:

2017/09/06 00:21:40 [warn] 881#881: *50635 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/0/01/0000000010 while reading upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /remote.php/dav/files/user/FILE.mp3 HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock:”, host: “my_url.io”

2017/09/06 01:08:24 [error] 879#879: *52191 upstream timed out (110: Connection timed out) while reading response header from upstream, client: CLIENT-IP, server: my_url.io, request: “MOVE /remote.php/dav/uploads/userXY/3941241390/.file HTTP/1.1”, upstream: “http://127.0.0.1:82/remote.php/dav/uploads/userXY/3941241390/.file”, host: “my_url.io”

2017/09/06 01:12:46 [error] 878#878: *51474 upstream timed out (110: Connection timed out) while reading response header from upstream, client: CLIENT-IP, server: my_url.io, request: “MOVE /remote.php/dav/uploads/userXY/3409823176/.file HTTP/1.1”, upstream: “http://127.0.0.1:82/remote.php/dav/uploads/userXY/3409823176/.file”, host: “my_url.io”

2017/09/06 01:28:22 [error] 880#880: *53018 upstream timed out (110: Connection timed out) while reading response header from upstream, client: CLIENT-IP, server: my_url.io, request: “MOVE /remote.php/webdav/FILE.mp4 HTTP/2.0”, upstream: “http://127.0.0.1:82/remote.php/webdav/FILE.mp4”, host: “my_url.io”

2017/09/06 01:35:12 [error] 879#879: *53192 upstream timed out (110: Connection timed out) while reading response header from upstream, client: CLIENT-IP, server: my_url.io, request: “MOVE /remote.php/dav/uploads/userXY/1672020373/.file HTTP/1.1”, upstream: “http://127.0.0.1:82/remote.php/dav/uploads/userXY/1672020373/.file”, host: “my_url.io”

2017/09/06 01:55:46 [error] 879#879: *54854 upstream timed out (110: Connection timed out) while reading response header from upstream, client: CLIENT-IP, server: my_url.io, request: “MOVE /remote.php/dav/uploads/userXY/3616606520/.file HTTP/1.1”, upstream: “http://127.0.0.1:82/remote.php/dav/uploads/userXY/3616606520/.file”, host: “my_url.io”

2017/09/06 02:14:09 [error] 880#880: *55439 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock”, host: “my_url.io”

2017/09/06 02:14:09 [error] 880#880: *55443 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock”, host: “my_url.io”

2017/09/06 02:14:09 [error] 880#880: *55447 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock”, host: “my_url.io”

2017/09/06 02:18:32 [error] 878#878: *55464 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock”, host: “my_url.io”

2017/09/06 02:18:32 [error] 878#878: *55466 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock”, host: “my_url.io”

2017/09/06 02:18:32 [error] 878#878: *55473 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /status.php HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock”, host: “my_url.io”

2017/09/06 02:24:34 [error] 879#879: *55527 upstream timed out (110: Connection timed out) while reading response header from upstream, client: CLIENT-IP, server: my_url.io, request: “GET /apps/activity/ HTTP/2.0”, upstream: “http://127.0.0.1:82/apps/activity/”, host: “my_url.io”

2017/09/06 02:29:34 [error] 879#879: *55534 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, request: “GET /apps/activity/ HTTP/1.1”, upstream: “fastcgi://unix:/run/php/php7.1-fpm.sock”, host: “my_url.io”


I just skimmed over your post. Looks like a bug for me. Please report to files antivirus github repository.

The issue was reported to github: https://github.com/nextcloud/files_antivirus/issues/36