Malformed response from server then uploading to external SMB storage on Debian 12

Hello everyone I think I’m having some issues with php or the smb connection to the external storage, basically, if I try to make too many (usually more than 30)
uploads to an external smb storage attached to nextcloud, i get the malformed response from server error and some files get locked, I have then to wait a bit (probably the next php cronjob cycle) to get the files unlocked and be able to work with them, I’ve read a few posts in which other users reported a problem similar to mine but they fixed by changing their php-smbclient, however I’m on debian and I don’t have that package available, is there anything else that I can do?

Nextcloud version: Nextcloud Hub 6 (27.1.3)
Operating system and version: Debian GNU/Linux 12 (bookworm)
Apache or nginx version: Apache/2.4.57 (Debian)
PHP version: PHP 8.2.7

The issue you are facing: “Icewind\SMB\Exception\Exception: Malformed state response from server”
Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Add smb external storage to nextcloud
  2. Upload folder with a lot (eg: 93) files of about 15 kb each
  3. Get “Malformed state response from server” exception, the upload stops halfway through, some files become temporarly locked
  4. Wait a few minutes, files get unlocked, can delete folder again.

Issue does not happen if the same kind of upoload is done directly to the nextcloud storage.

The output of your Nextcloud log in Admin > Logging:

[webdav] Error: Icewind\SMB\Exception\Exception: Malformed state response from server at <<closure>>

 0. /dati/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php line 217
    Icewind\SMB\Wrapped\Parser->parseStat()
 1. /dati/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php line 191
    Icewind\SMB\Wrapped\Share->stat()
 2. /dati/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php line 670
    OCA\Files_External\Lib\Storage\SMB->getFileInfo()
 3. /dati/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 224
    OCA\Files_External\Lib\Storage\SMB->file_exists()
 4. /dati/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 224
    OC\Files\Storage\Wrapper\Wrapper->file_exists()
 5. /dati/www/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php line 244
    OC\Files\Storage\Wrapper\Wrapper->file_exists()
 6. /dati/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 224
    OC\Files\Storage\Wrapper\Availability->file_exists()
 7. /dati/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 224
    OC\Files\Storage\Wrapper\Wrapper->file_exists()
 8. /dati/www/nextcloud/apps/files_trashbin/lib/Trashbin.php line 330
    OC\Files\Storage\Wrapper\Wrapper->file_exists()
 9. /dati/www/nextcloud/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php line 108
    OCA\Files_Trashbin\Trashbin::move2trash()
10. /dati/www/nextcloud/apps/files_trashbin/lib/Trash/TrashManager.php line 102
    OCA\Files_Trashbin\Trash\LegacyTrashBackend->moveToTrash()
11. /dati/www/nextcloud/apps/files_trashbin/lib/Storage.php line 202
    OCA\Files_Trashbin\Trash\TrashManager->moveToTrash()
12. /dati/www/nextcloud/apps/files_trashbin/lib/Storage.php line 102
    OCA\Files_Trashbin\Storage->doDelete()
13. /dati/www/nextcloud/apps/files_accesscontrol/lib/StorageWrapper.php line 194
    OCA\Files_Trashbin\Storage->unlink()
14. /dati/www/nextcloud/lib/private/Files/View.php line 1161
    OCA\FilesAccessControl\StorageWrapper->unlink()
15. /dati/www/nextcloud/lib/private/Files/View.php line 702
    OC\Files\View->basicOperation()
16. /dati/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 536
    OC\Files\View->unlink()
17. /dati/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 179
    OCA\DAV\Connector\Sabre\File->delete()
18. /dati/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 281
    Sabre\DAV\Tree->delete()
19. /dati/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpDelete()
20. /dati/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
    Sabre\DAV\Server->emit()
21. /dati/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
    Sabre\DAV\Server->invokeMethod()
22. /dati/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
    Sabre\DAV\Server->start()
23. /dati/www/nextcloud/apps/dav/lib/Server.php line 365
    Sabre\DAV\Server->exec()
24. /dati/www/nextcloud/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
25. /dati/www/nextcloud/remote.php line 172
    require_once("/dati/www/nextc ... p")

DELETE /remote.php/dav/files/admin/Assistenza/test3123/LAVTUV/11847-1571-MoricoDomenicoECSnc.LavTUV
from 192.168.200.40 by admin at 2023-10-30T09:01:31+00:00


[PHP] Error: Undefined array key "attributes" at /dati/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php#155

DELETE /remote.php/dav/files/admin/Assistenza/test3123/LAVTUV/11847-1571-MoricoDomenicoECSnc.LavTUV
from 192.168.200.40 by admin at 2023-10-30T09:01:31+00:00

// this is just a snippet, there are two exceptions like this for each file getting locked

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'id',
  'passwordsalt' => 'salt',
  'secret' => 'secret',
  'trusted_domains' =>
  array (
    0 => 'web01.mydomwin.local',
  ),
  'trusted_proxies' => ['192.168.200.37'],
  'datadirectory' => '/dati/nextcloud',
  'dbtype' => 'mysql',
  'version' => '27.1.3.2',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_admin',
  'dbpassword' => 'secret',
  'installed' => true,
  'allow_local_remote_servers' =>
  array (
    'True' => '',
  ),
  'maintenance' => false,
  'htaccess.RewriteBase' => '/',
  'skeletondirectory' => '',
  'mail_from_address' => 'cloud',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'mydomwin.local',
  'mail_smtpport' => '25',
  'default_phone_region' => 'IT',
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'memcache.locking' => '\OC\Memcache\Redis',
  'memcache.local' => '\OC\Memcache\Redis',
  'memcache.distributed' => '\OC\Memcache\Redis',
  'redis' => [
    'host'     => '/run/redis/redis-server.sock',
    'port'     => 0,
    'timeout'  => 1.5,
  ]
);

The output of your Apache/nginx/system log in /var/log/____:

root@web01:~# tail -f /var/log/apache2/error.log
[Mon Oct 30 00:00:01.393381 2023] [mpm_prefork:notice] [pid 521] AH00163: Apache/2.4.57 (Debian) OpenSSL/3.0.11 configured -- resuming normal operations
[Mon Oct 30 00:00:01.393445 2023] [core:notice] [pid 521] AH00094: Command line: '/usr/sbin/apache2'
[Mon Oct 30 09:59:18.837766 2023] [proxy_fcgi:error] [pid 19146] (70007)The timeout specified has expired: [client 192.168.200.37:51038] AH01075: Error dispatching request to : (polling)
[Mon Oct 30 10:16:29.881452 2023] [proxy_fcgi:error] [pid 23605] (70007)The timeout specified has expired: [client 192.168.200.37:47912] AH01075: Error dispatching request to : (polling)

// no other apache logfiles reported anything during the timeframe in which i go the exception.