nextcloud / previewgenerator

Nextcloud app to do preview generation in the background.
https://apps.nextcloud.com/apps/previewgenerator
GNU Affero General Public License v3.0
450 stars 56 forks source link

Malformed state response from server (SMB) #305

Closed dacmot closed 1 year ago

dacmot commented 2 years ago

I'm having many difficulties when running preview:generate-all. The main one being an error when scanning a folder. The other is folders just being skipped over, even if they don't have .nomedia (see also https://github.com/nextcloud/previewgenerator/issues/77#issuecomment-354364318)

The error is:

sudo -u www-data php /var/www/nextcloud/occ preview:generate-all -vvv
...
022-07-22T02:44:04+00:00 Scanning folder /mo/files/Pictures/cats/112_0305
2022-07-22T02:44:04+00:00 Generating previews for /mo/files/Pictures/cats/112_0305/IMGP2803.JPG
2022-07-22T02:44:04+00:00 Generating previews for /mo/files/Pictures/cats/112_0305/IMGP2804.JPG
2022-07-22T02:44:04+00:00 Scanning folder /mo/files/Pictures/dogs
2022-07-22T02:44:04+00:00 
2022-07-22T02:44:04+00:00 In Parser.php line 157:
2022-07-22T02:44:04+00:00                                         
2022-07-22T02:44:04+00:00   [Icewind\SMB\Exception\Exception]     
2022-07-22T02:44:04+00:00   Malformed state response from server  
2022-07-22T02:44:04+00:00                                         
2022-07-22T02:44:04+00:00 
2022-07-22T02:44:04+00:00 Exception trace:
2022-07-22T02:44:04+00:00   at /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Parser.php:157
2022-07-22T02:44:04+00:00  Icewind\SMB\Wrapped\Parser->parseStat() at /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Wrapped/Share.php:217
2022-07-22T02:44:04+00:00  Icewind\SMB\Wrapped\Share->stat() at /var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php:193
2022-07-22T02:44:04+00:00  OCA\Files_External\Lib\Storage\SMB->getFileInfo() at /var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php:668
2022-07-22T02:44:04+00:00  OCA\Files_External\Lib\Storage\SMB->file_exists() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:227
2022-07-22T02:44:04+00:00  OC\Files\Storage\Wrapper\Wrapper->file_exists() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:227
2022-07-22T02:44:04+00:00  OC\Files\Storage\Wrapper\Wrapper->file_exists() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Availability.php:244
2022-07-22T02:44:04+00:00  OC\Files\Storage\Wrapper\Availability->file_exists() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:227
2022-07-22T02:44:04+00:00  OC\Files\Storage\Wrapper\Wrapper->file_exists() at /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php:227
2022-07-22T02:44:04+00:00  OC\Files\Storage\Wrapper\Wrapper->file_exists() at /var/www/nextcloud/lib/private/Files/View.php:1345
2022-07-22T02:44:04+00:00  OC\Files\View->getCacheEntry() at /var/www/nextcloud/lib/private/Files/View.php:1390
2022-07-22T02:44:04+00:00  OC\Files\View->getFileInfo() at /var/www/nextcloud/lib/private/Files/Node/Root.php:205
2022-07-22T02:44:04+00:00  OC\Files\Node\Root->get() at /var/www/nextcloud/lib/private/Files/Node/Folder.php:137
2022-07-22T02:44:04+00:00  OC\Files\Node\Folder->get() at /var/www/nextcloud/lib/private/Files/Node/Folder.php:146
2022-07-22T02:44:04+00:00  OC\Files\Node\Folder->nodeExists() at /var/www/nextcloud/apps/previewgenerator/lib/Command/Generate.php:192
2022-07-22T02:44:04+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/nextcloud/apps/previewgenerator/lib/Command/Generate.php:203
2022-07-22T02:44:04+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/nextcloud/apps/previewgenerator/lib/Command/Generate.php:203
2022-07-22T02:44:04+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/nextcloud/apps/previewgenerator/lib/Command/Generate.php:203
2022-07-22T02:44:04+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/nextcloud/apps/previewgenerator/lib/Command/Generate.php:183
2022-07-22T02:44:04+00:00  OCA\PreviewGenerator\Command\Generate->generateUserPreviews() at /var/www/nextcloud/apps/previewgenerator/lib/Command/Generate.php:135
2022-07-22T02:44:04+00:00  OCA\PreviewGenerator\Command\Generate->execute() at /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
2022-07-22T02:44:04+00:00  Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:1009
2022-07-22T02:44:04+00:00  Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:273
2022-07-22T02:44:04+00:00  Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:149
2022-07-22T02:44:04+00:00  Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:211
2022-07-22T02:44:04+00:00  OC\Console\Application->run() at /var/www/nextcloud/console.php:100
2022-07-22T02:44:04+00:00  require_once() at /var/www/nextcloud/occ:11
2022-07-22T02:44:04+00:00 
2022-07-22T02:44:04+00:00 preview:generate-all [-p|--path [PATH]] [--] [<user_id>...]

This error always happens on that folder. If I put --path=/mo/files/Pictures/dogs, I get the error right away. I tried to see what could be strange about that folder but I can't figure it out. It has a couple hundred pictures in it, no bigger than 10M, some more pictures in sub-folders, two videos around 30M. Similar to other folders that have no issues. All permissions look fine. No hidden file or folder.

My setup is:

Since there is no PHP smbclient in Ubuntu 20.04, I installed 1.0.6 from pecl. However, I could not tell the difference as I still got the error. I also can't tell which client is being used.

All of my pictures are stored on a samba share (Helios4 NAS running OpenMediaVault). The NAS and nextcloud servers are both wired on GbE. I have no issues accessing the pictures from nextcloud either from the web, or the android app, whether on my home wi-fi or remotely.

Let me know if I'm missing any info.

joshtrichards commented 1 year ago

Hi @dacmot - Thanks for the report.

This doesn't look like a previewgenerator issue. It's an issue either in an upstream dependency used by NC server or with your SMB server (maybe). The code being triggered is after a simulated stat() call to get information like file modification time, mode, and size from your SMB share. The error suggests the output being received from the SMB host doesn't contain the attributes / look at all like NC expects.

Since there is no PHP smbclient in Ubuntu 20.04, I installed 1.0.6 from pecl. However, I could not tell the difference as I still got the error. I also can't tell which client is being used.

Wrapped means it's using the smbclient binary. Native means it's using php-smbclient.

If you're still experiencing this problem, I suggest closing this one and reporting it against NC Server since that's the more appropriate place for this Issue (nothing can be done about it in previewgenerator).

But if you're ambitious - and to get a head start on isolating the cause - capture the output of running this from the command-line of your NC server:

smbclient '\\<Target IP>\<Target Dir>' -U <Username>

You should get prompted for a password (if any) and go ahead and enter it.

Then at the smb: \> prompt try running a few iterations of the command that things are failing on which is an allinfo query to your SMB host:

allinfo Pictures/cats allinfo Pictures/cats/somefile.jpg etc

The output should look a little like this:

https://github.com/icewind1991/SMB/blob/f944fae8b14d6807f7f58e76c30bbdffc0b3727a/tests/ParserTest.php#L41-L52

But don't post the results here - send it in with your report to the NC Server repository. :-)

P.S. There have been some upstream changes in the SMB module so it's entirely possible this is resolved in a newer NC version - https://github.com/icewind1991/SMB/commits/master

dacmot commented 1 year ago

Thanks a lot for checking this out!

Since I'm still on v25 because of Debian Bulleye's php 7.4, I'll keep it in mind when I upgrade.