server icon indicating copy to clipboard operation
server copied to clipboard

SFTP External Storage error

Open Teke-lili opened this issue 4 years ago • 12 comments

Steps to reproduce

  1. Setup external storage SFTP
  2. Check Connection
  3. Open external storage
  4. Upload File with size larger than 524.888 bytes
  5. Try download the file image

Expected behaviour

  1. Setup external storage SFTP
  2. Check Connection
  3. Open external storage
  4. Upload File with size larger than 524.888 bytes
  5. Download the file

Actual behaviour

  1. Setup external storage SFTP
  2. Check Connection
  3. Open external storage
  4. Upload File with size larger than 524.888 bytes
  5. Try to download file
  6. Error Page Displayed image

Server configuration

**Operating system: Linux 3.10.0-1160.6.1.el7.x86_64 x86_64

**Web server:

**Database: Type: mysql Version: 10.3.25 **PHP version: PHP Version 7.4.15

**Nextcloud version: Nextcloud 20.0.7

**Updated from an older Nextcloud/ownCloud or fresh install: Updated from previous stable version

**Where did you install Nextcloud from:

Signing status:

Signing status No errors have been found.

List of activated apps:

Activated Apps Accessibility 1.6.0 Activity 2.13.4 Brute-force settings 2.0.1 Calendar 2.1.3 Collaborative tags 1.10.0 Comments 1.10.0 Community Document Server 0.1.9 Contacts 3.4.3 Contacts Interaction 1.1.0 Dashboard 7.0.0 Default encryption module 2.8.1 Deleted files 1.10.1 Element for Nextcloud 0.7.2 End-to-End Encryption 1.6.2 EPUB/CBZ/PDF ebook reader 1.4.5 External storage support 1.11.1 External Storage: OneDrive 1.1.0 Extract 1.3.0 Federation 1.10.1 File sharing 1.12.2 First run wizard 2.9.0 Group folders 8.2.0 Log Reader 2.5.0 Maps 0.1.8 Monitoring 1.10.0 Nextcloud announcements 1.9.0 Notifications 2.8.0 Password policy 1.10.1 Passwords 2021.2.0 PDF viewer 2.0.1 Photos 1.2.3 Privacy 1.4.0 Ransomware protection 1.8.0 Recommendations 0.8.0 Right click 0.17.0 Share by mail 1.10.0 Support 1.3.0 Talk 10.0.6 Tasks 0.13.6 Text 3.1.0 Theming 1.11.0 Update notification 1.10.0 Usage survey 1.8.0 User status 1.0.1 Versions 1.13.0 Video player 1.9.0 Weather status 1.0.0

Nextcloud configuration:

Nextcloud configuration { "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "www.webserver.cloud" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "mysql", "version": "20.0.7.1", "overwrite.cli.url": "https:\/\/www.webserver.cloud", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "mysql.utf8mb4": true, "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "mail_smtpmode": "sendmail", "mail_smtpsecure": "tls", "mail_sendmailmode": "pipe", "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_smtpauthtype": "LOGIN", "mail_smtpport": "587", "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "memcache.local": "\\OC\\Memcache\\APCu", "maintenance": false, "loglevel": 2, "theme": "", "enable_certificate_management": true } }

**Are you using external storage, if yes which one: SFTP, WebDAV

Are you using encryption: yes on WebDav, no on SFTP

Are you using an external user-backend, if yes which one: No

Client configuration

**Browser: Safari, Firefox

**Operating system:OS X 10.14.6, 10.15.7, Windows 7, Windows 10

Logs

Web server error log

Nextcloud log (data/nextcloud.log)

Nextcloud log

[PHP] Error: Error: fopen(sftpread://NextcloudExternal/_Shared_Remote/PhotoArchiv/Peter/DSC_0007.JPG): failed to open stream: "OCA\Files_External\Lib\Storage\SFTPReadStream::stream_open" call failed at /var/www/virtual/webserver/www.webserver.cloud/apps/files_external/lib/Lib/Storage/SFTP.php#378 at <>

  1. <> OC\Log\ErrorHandler::onError(2, "fopen(sftpread: ... d", "/var/www/virtua ... p", 378, {path: "Nextclou ... l})
  2. /var/www/virtual/webserver/www.webserver.cloud/apps/files_external/lib/Lib/Storage/SFTP.php line 378 fopen("sftpread://Next ... G", "r", false, null)
  3. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 300 OCA\Files_External\Lib\Storage\SFTP->fopen("NextcloudExtern ... G", "r")
  4. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Availability.php line 315 OC\Files\Storage\Wrapper\Wrapper->fopen("NextcloudExtern ... G", "r")
  5. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Encryption.php line 480 OC\Files\Storage\Wrapper\Availability->fopen("NextcloudExtern ... G", "r")
  6. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 300 OC\Files\Storage\Wrapper\Encryption->fopen("NextcloudExtern ... G", "r")
  7. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/View.php line 1165 OC\Files\Storage\Wrapper\Wrapper->fopen("NextcloudExtern ... G", "r")
  8. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/View.php line 1001 OC\Files\View->basicOperation("fopen", "/webserver_cloud ... G", ["read"], "r")
  9. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Node/File.php line 115 OC\Files\View->fopen("/webserver_cloud ... G", "r")
  10. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Preview/ProviderV2.php line 86 OC\Files\Node\File->fopen("r")
  11. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Preview/Image.php line 50 OC\Preview\ProviderV2->getLocalFile(OC\Files\Node\File {})
  12. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Preview/GeneratorHelper.php line 63 OC\Preview\Image->getThumbnail(OC\Files\Node\File {}, 4096, 4096)
  13. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Preview/Generator.php line 244 OC\Preview\GeneratorHelper->getThumbnail(OC\Preview\JPEG {}, OC\Files\Node\File {}, 4096, 4096)
  14. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Preview/Generator.php line 140 OC\Preview\Generator->getMaxPreview(OC\Files\SimpleFS\SimpleFolder {}, OC\Files\Node\File {}, "image/jpeg", "")
  15. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Preview/Generator.php line 109 OC\Preview\Generator->generatePreviews(OC\Files\Node\File {}, [{width: 32,heig ... }], "image/jpeg")
  16. /var/www/virtual/webserver/www.webserver.cloud/lib/private/PreviewManager.php line 190 OC\Preview\Generator->getPreview(OC\Files\Node\File {}, 32, 32, true, "fill", null)
  17. /var/www/virtual/webserver/www.webserver.cloud/core/Controller/PreviewController.php line 170 OC\PreviewManager->getPreview(OC\Files\Node\File {}, 32, 32, true, "fill")
  18. /var/www/virtual/webserver/www.webserver.cloud/core/Controller/PreviewController.php line 143 OC\Core\Controller\PreviewController->fetchPreview(OC\Files\Node\File {}, 32, 32, false, true, "fill")
  19. /var/www/virtual/webserver/www.webserver.cloud/lib/private/AppFramework/Http/Dispatcher.php line 169 OC\Core\Controller\PreviewController->getPreviewByFileId(38764, 32, 32, false, true, "fill")
  20. /var/www/virtual/webserver/www.webserver.cloud/lib/private/AppFramework/Http/Dispatcher.php line 100 OC\AppFramework\Http\Dispatcher->executeController(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
  21. /var/www/virtual/webserver/www.webserver.cloud/lib/private/AppFramework/App.php line 152 OC\AppFramework\Http\Dispatcher->dispatch(OC\Core\Controller\PreviewController {}, "getPreviewByFileId")
  22. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Route/Router.php line 309 OC\AppFramework\App::main("OC\Core\Controller\PreviewController", "getPreviewByFileId", OC\AppFramework\ ... {}, {_route: "core.P ... "})
  23. /var/www/virtual/webserver/www.webserver.cloud/lib/base.php line 1008 OC\Route\Router->match("/core/preview")
  24. /var/www/virtual/webserver/www.webserver.cloud/index.php line 37 OC::handleRequest()

GET /index.php/core/preview?fileId=38764&x=32&y=32 from 91.56.150.220 by webserver_cloud at 2021-02-24T18:51:32+00:00

SFTP Server Side Log

SSH Server Side log
<session id="9915" service="SSH" remoteAddress=«xxx.xxx.xxx.xxx:yyyyy» virtualAccount=«Name» windowsAccount=«NameW»/>
<channel type="session" id="1"/>
<sfs moduleName="FlowSfsWin" mountPath="/NextcloudExternal" code="90000" desc="Transferring file ended.">
  <parameters path="F:\_remote_nextcloud\_Shared_Remote\PhotoArchiv\Peter\DSC_0007.JPG" timeMs="238" bytesRead="524288" bytesWritten="0" readRangeOffset="0" readRangeLength="524288" writeRangeOffset="0" writeRangeLength="0" createdNewFile="false" resizedFile="false" endedBy="Client"/>
  <help message="File transfer ended by client."/>
</sfs>

Additional Information

The closed issue https://github.com/nextcloud/server/issues/20979 referred to changes in apps/files_external/lib/Lib/Storage/SFT.php. Editing the SFTP.php file to remove the special cases for read/write fixes the problem. However chunk size for transfer via SFTP is then limited to 8192bytes resulting in numerous connection attempts via SFTP to the server. Changing the definitions request_chunk(256 * 1024) setting in apps/files_external/lib/Lib/Storage/SFTPReadStream.php enlarges the chunk size but does not fix the problem.

Teke-lili avatar Feb 24 '21 19:02 Teke-lili

Same Issue in Version 21.0.0

running-spec avatar Mar 04 '21 23:03 running-spec

I suppose this is still valid in NC21.0.2?

szaimen avatar Jun 25 '21 11:06 szaimen

I did not test on NC21.0.2. However, "apps/files_external/lib/Lib/Storage/SFTP.php" in NC21.0.2 is identical to NC20.0.11, which I am using now. The issue still persists.

Teke-lili avatar Jul 15 '21 18:07 Teke-lili

Did not want to close the issue. Wrong button.

Teke-lili avatar Jul 15 '21 18:07 Teke-lili

Hi, please update to 24.0.9 or better 25.0.3 and report back if it fixes the issue. Thank you!

My goal is to add a label like e.g. 25-feedback to this ticket of an up-to-date major Nextcloud version where the bug could be reproduced. However this is not going to work without your help. So thanks for all your effort!

If you don't manage to reproduce the issue in time and the issue gets closed but you can reproduce the issue afterwards, feel free to create a new bug report with up-to-date information by following this link: https://github.com/nextcloud/server/issues/new?assignees=&labels=bug%2C0.+Needs+triage&template=BUG_REPORT.yml&title=%5BBug%5D%3A+

szaimen avatar Jan 23 '23 10:01 szaimen

This is very much still an issue. All uploads through nextcloud clients fail if targeted to the sftp folder or its subfolders. Even downloading a file no larger than 10 MB from the sftp storage fail.

When moving files from local to the sftp folder through the webgui, this also fails. It is very unstable, right now I sync local files with nextcloud client to then manually transfer them to the sftp target through filezilla, this works but is not the intended use.

occ command to scan all files also takes ages to complete, and when syncing a new client with nextcloud it imposes problems. Currently been waiting for "checking changes in remote ...", it has taken a day already and still no progress. This results in an empty folder instead of a populated folder for the workstation running the nextcloud client. (virtual files and folders functionality)

Using the IOS client I get the same behavior when uploading or downloading files. Browsing through the directories also need a refresh after opening every folder because it shows no content, after refresh it's able to at least show the contents but other file operations fail.

I've seen these issues since 2019, and paused my use of nextcloud for over 2 years before trying again.

Nextcloud is running on a ryzen 5 3600 CPU with 64GB of RAM, This is running on a dedicated root server at Hetzner. I'm currently on the latest version of nextcloud, The configuration overview shows 0 issues.

Hope the extra info here is an added value in determining a fix for the issue.

(my sftp target is a synology box connected through wireguard tunnel to the cloud environment (offloaded to firewalls on both ends, normal transfers have the capability of using my full bandwidth of 1 Gbps syncro)

sachz19 avatar Feb 10 '23 13:02 sachz19

which nc version did you test?

szaimen avatar Feb 10 '23 14:02 szaimen

I’ve tested it with the last 3 main versions of NC. Current tests (with the same results as all previous versions I tested) is run with:

NC: 25.0.3

NC Client Windows: 3.6.6.20230119 (will update to 3.7.3 in the near future, going to give current version a chance to hopefully complete detecting changes and start the actual sync)

NC Client IOS: 4.6.0.19

NC Android: Not my own device, according to user latest version available for installation (checked today for uipdates)

Hope this info helps with the need to get more information.

From: Simon L. @.> Sent: Friday, 10 February 2023 15:22 To: nextcloud/server @.> Cc: sachz19 @.>; Comment @.> Subject: Re: [nextcloud/server] SFTP External Storage error (#25788)

which nc version did you test?

— Reply to this email directly, view it on GitHub https://github.com/nextcloud/server/issues/25788#issuecomment-1425878319 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AXLUW3HZU7D6V2MNKF5K4I3WWZFIXANCNFSM4YFEKDHQ . You are receiving this because you commented. https://github.com/notifications/beacon/AXLUW3AN5STLAU5G7RGW3QDWWZFIXA5CNFSM4YFEKDH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOKT6S2LY.gif Message ID: @.*** @.***> >

sachz19 avatar Feb 10 '23 15:02 sachz19

This is the only error related to this issue I can find in my system logs:

User XXXX still has unscanned files after running background scan, background scan might be stopped prematurely

From: Simon L. @.> Sent: Friday, 10 February 2023 15:22 To: nextcloud/server @.> Cc: sachz19 @.>; Comment @.> Subject: Re: [nextcloud/server] SFTP External Storage error (#25788)

which nc version did you test?

— Reply to this email directly, view it on GitHub https://github.com/nextcloud/server/issues/25788#issuecomment-1425878319 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AXLUW3HZU7D6V2MNKF5K4I3WWZFIXANCNFSM4YFEKDHQ . You are receiving this because you commented. https://github.com/notifications/beacon/AXLUW3AN5STLAU5G7RGW3QDWWZFIXA5CNFSM4YFEKDH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOKT6S2LY.gif Message ID: @.*** @.***> >

sachz19 avatar Feb 10 '23 15:02 sachz19

I’m currently testing with the latest version of the nc client on windows, currently I’m seeing the same behaviour.

From: Simon L. @.> Sent: Friday, 10 February 2023 15:22 To: nextcloud/server @.> Cc: sachz19 @.>; Comment @.> Subject: Re: [nextcloud/server] SFTP External Storage error (#25788)

which nc version did you test?

— Reply to this email directly, view it on GitHub https://github.com/nextcloud/server/issues/25788#issuecomment-1425878319 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AXLUW3HZU7D6V2MNKF5K4I3WWZFIXANCNFSM4YFEKDHQ . You are receiving this because you commented. https://github.com/notifications/beacon/AXLUW3AN5STLAU5G7RGW3QDWWZFIXA5CNFSM4YFEKDH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOKT6S2LY.gif Message ID: @.*** @.***> >

sachz19 avatar Feb 11 '23 21:02 sachz19

Hi, thanks for looking at the problem. I changed the external file access to WebDAV to circumvent the issue. To check I have re-initiated SFTP access to external storage. I am on Nextcloud Hub 3 (25.0.3). NextcloudVersion_230219 SFTP Access is arranged through private account (no admin rights) and marked as successful. SFTP_Access_230219 The original issue showing the error page when trying to download a previously uploaded file with file size larger than 524888 bytes disappeared. However, system log of Nexcloud shows multiple error events starting with error:

[PHP] Error: Error: Undefined array key "mtime" at /var/www/virtual/webserver/www.webserver.cloud/apps/files_external/lib/Lib/Storage/SFTP.php#459 at <>

  1. /var/www/virtual/webserver/www.webserver.cloud/apps/files_external/lib/Lib/Storage/SFTP.php line 459 OC\Log\ErrorHandler::onError(2, "Undefined array key "mtime"", "/var/www/virtua ... p", 459)
  2. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Common.php line 190 OCA\Files_External\Lib\Storage\SFTP->stat("")
  3. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Common.php line 722 OC\Files\Storage\Common->filemtime("")
  4. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 599 OC\Files\Storage\Common->getMetaData("")
  5. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/PermissionsMask.php line 140 OC\Files\Storage\Wrapper\Wrapper->getMetaData("")
  6. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 599 OC\Files\Storage\Wrapper\PermissionsMask->getMetaData("")
  7. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Availability.php line 447 OC\Files\Storage\Wrapper\Wrapper->getMetaData("")
  8. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Encryption.php line 196 OC\Files\Storage\Wrapper\Availability->getMetaData("")
  9. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 599 OC\Files\Storage\Wrapper\Encryption->getMetaData("")
  10. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 599 OC\Files\Storage\Wrapper\Wrapper->getMetaData("")
  11. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Cache/Scanner.php line 116 OC\Files\Storage\Wrapper\Wrapper->getMetaData("")
  12. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Cache/Scanner.php line 154 OC\Files\Cache\Scanner->getData("")
  13. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/View.php line 1502 OC\Files\Cache\Scanner->scanFile("")
  14. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Node/Folder.php line 101 OC\Files\View->getDirectoryContent("/", "", OC\Files\Node\LazyUserFolder {})
  15. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Connector/Sabre/Directory.php line 260 OC\Files\Node\Folder->getDirectoryListing()
  16. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php line 67 OCA\DAV\Connector\Sabre\Directory->getChildren()
  17. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php line 112 OCA\DAV\Connector\Sabre\CommentPropertiesPlugin->cacheDirectory(OCA\DAV\Files\FilesHome {})
  18. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89 OCA\DAV\Connector\Sabre\CommentPropertiesPlugin->handleGetProperties(Sabre\DAV\PropFind {}, OCA\DAV\Files\FilesHome {})
  19. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1052 Sabre\DAV\Server->emit("propFind", [Sabre\DAV\PropF ... }])
  20. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 984 Sabre\DAV\Server->getPropertiesByNode(Sabre\DAV\PropFind {}, OCA\DAV\Files\FilesHome {})
  21. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1662 Sabre\DAV\Server->getPropertiesIteratorForPath("files/user", ["{DAV:}getlastm ... "], 1)
  22. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1647 Sabre\DAV\Server->writeMultiStatus(Sabre\Xml\Writer ... ]}, Generator {}, false)
  23. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 346 Sabre\DAV\Server->generateMultiStatus(Generator {}, false)
  24. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89 Sabre\DAV\CorePlugin->httpPropFind(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
  25. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472 Sabre\DAV\Server->emit("method:PROPFIND", [Sabre\HTTP\Requ ... }])
  26. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253 Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
  27. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321 Sabre\DAV\Server->start()
  28. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Server.php line 360 Sabre\DAV\Server->exec()
  29. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/appinfo/v2/remote.php line 35 OCA\DAV\Server->exec()
  30. /var/www/virtual/webserver/www.webserver.cloud/remote.php line 171 require_once("/var/www/virtua ... p")

PROPFIND /remote.php/dav/files/user/ from by user at 2023-02-19T12:43:26+00:00

The error code above seems to be a result of the upload to the external storage via SFTP. Nevertheless, the file itself has been uploaded to the external storage. Reload of the nextcloud external storage shows the file available to nextcloud. The download attempt results in error message in the system log: [PHP] Error: Error: fopen(sftpread://NextcloudExternal/_Shared_Remote/SFTP_Upload/Panorama_PizBorel.jpg): Failed to open stream: "OCA\Files_External\Lib\Storage\SFTPReadStream::stream_open" call failed at /var/www/virtual/webserver/www.webserver.cloud/apps/files_external/lib/Lib/Storage/SFTP.php#381 at <> 0. <> OC\Log\ErrorHandler::onError(2, "fopen(sftpread: ... d", "/var/www/virtua ... p", 381)

  1. /var/www/virtual/webserver/www.webserver.cloud/apps/files_external/lib/Lib/Storage/SFTP.php line 381 fopen("sftpread://Next ... g", "r", false, null)
  2. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Common.php line 199 OCA\Files_External\Lib\Storage\SFTP->fopen("NextcloudExtern ... g", "r")
  3. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 247 OC\Files\Storage\Common->file_get_contents("NextcloudExtern ... g")
  4. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 247 OC\Files\Storage\Wrapper\Wrapper->file_get_contents("NextcloudExtern ... g")
  5. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Availability.php line 264 OC\Files\Storage\Wrapper\Wrapper->file_get_contents("NextcloudExtern ... g")
  6. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Encryption.php line 228 OC\Files\Storage\Wrapper\Availability->file_get_contents("NextcloudExtern ... g")
  7. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 247 OC\Files\Storage\Wrapper\Encryption->file_get_contents("NextcloudExtern ... g")
  8. /var/www/virtual/webserver/www.webserver.cloud/apps/ransomware_protection/lib/StorageWrapper.php line 240 OC\Files\Storage\Wrapper\Wrapper->file_get_contents("NextcloudExtern ... g")
  9. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/View.php line 1181 OCA\RansomwareProtection\StorageWrapper->file_get_contents("NextcloudExtern ... g")
  10. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/View.php line 600 OC\Files\View->basicOperation("file_get_contents", "/user/files/SF ... g", ["read"])
  11. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Node/File.php line 56 OC\Files\View->file_get_contents("/user/files/SF ... g")
  12. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Metadata/Provider/ExifProvider.php line 71 OC\Files\Node\File->getContent()
  13. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Metadata/MetadataManager.php line 68 OC\Metadata\Provider\ExifProvider->execute(OC\Files\Node\File {})
  14. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Metadata/FileEventListener.php line 101 OC\Metadata\MetadataManager->generateMetadata(OC\Files\Node\File {}, false)
  15. /var/www/virtual/webserver/www.webserver.cloud/lib/private/EventDispatcher/ServiceEventListener.php line 87 OC\Metadata\FileEventListener->handle(OCP\Files\Events\Node\NodeWrittenEvent {})
  16. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251 OC\EventDispatcher\ServiceEventListener->__invoke(OCP\Files\Events\Node\NodeWrittenEvent {}, "OCP\Files\Eve ... t", Symfony\Componen ... {})
  17. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73 Symfony\Component\EventDispatcher\EventDispatcher->callListeners([Closure {},Closure {}], "OCP\Files\Eve ... t", OCP\Files\Events\Node\NodeWrittenEvent {})
  18. /var/www/virtual/webserver/www.webserver.cloud/lib/private/EventDispatcher/EventDispatcher.php line 88 Symfony\Component\EventDispatcher\EventDispatcher->dispatch(OCP\Files\Events\Node\NodeWrittenEvent {}, "OCP\Files\Eve ... t")
  19. /var/www/virtual/webserver/www.webserver.cloud/lib/private/EventDispatcher/EventDispatcher.php line 100 OC\EventDispatcher\EventDispatcher->dispatch("OCP\Files\Eve ... t", OCP\Files\Events\Node\NodeWrittenEvent {})
  20. /var/www/virtual/webserver/www.webserver.cloud/lib/private/Files/Node/HookConnector.php line 118 OC\EventDispatcher\EventDispatcher->dispatchTyped(OCP\Files\Events\Node\NodeWrittenEvent {})
  21. /var/www/virtual/webserver/www.webserver.cloud/lib/private/legacy/OC_Hook.php line 106 OC\Files\Node\HookConnector->postWrite(["/SFTP/Nextclou ... "])
  22. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Connector/Sabre/File.php line 471 OC_Hook::emit("OC_Filesystem", "post_write", ["/SFTP/Nextclou ... "])
  23. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Connector/Sabre/File.php line 398 OCA\DAV\Connector\Sabre\File->emitPostHooks(false)
  24. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Connector/Sabre/Directory.php line 151 OCA\DAV\Connector\Sabre\File->put(null)
  25. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 307 OCA\DAV\Connector\Sabre\Directory->createFile("Panorama_PizBorel.jpg", null)
  26. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 133 Sabre\DAV\Tree->copyNode(OCA\DAV\Upload\FutureFile {}, OCA\DAV\Connector\Sabre\Directory {}, "Panorama_PizBorel.jpg")
  27. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 163 Sabre\DAV\Tree->copy("uploads/user/w ... e", "files/user/SFT ... g")
  28. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Upload/ChunkingPlugin.php line 94 Sabre\DAV\Tree->move("uploads/user/w ... e", "files/user/SFT ... g")
  29. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Upload/ChunkingPlugin.php line 76 OCA\DAV\Upload\ChunkingPlugin->performMove("uploads/user/w ... e", "files/user/SFT ... g")
  30. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89 OCA\DAV\Upload\ChunkingPlugin->beforeMove("uploads/user/w ... e", "files/user/SFT ... g")
  31. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 603 Sabre\DAV\Server->emit("beforeMove", ["uploads/user/ ... "])
  32. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89 Sabre\DAV\CorePlugin->httpMove(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
  33. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472 Sabre\DAV\Server->emit("method:MOVE", [Sabre\HTTP\Requ ... }])
  34. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253 Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
  35. /var/www/virtual/webserver/www.webserver.cloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321 Sabre\DAV\Server->start()
  36. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/lib/Server.php line 360 Sabre\DAV\Server->exec()
  37. /var/www/virtual/webserver/www.webserver.cloud/apps/dav/appinfo/v2/remote.php line 35 OCA\DAV\Server->exec()
  38. /var/www/virtual/webserver/www.webserver.cloud/remote.php line 171 require_once("/var/www/virtua ... p")

MOVE /remote.php/dav/uploads/user/web-file-upload-c8654213e442a08dcc66948ae9deaed0-1676810665931/.file from by user at 2023-02-19T12:44:41+00:00

The test file has a file size of 10.672.356 bytes. Despite the error code in nexcloud it can be downloaded succesfully in reasonable time. However, the error messages in the nextcloud system log consists.

Teke-lili avatar Feb 19 '23 13:02 Teke-lili

I'm glad to hear the original reported symptom from OP @Teke-lili is no longer preventing downloads outright, but it sounds like there remain some cases where SFTP isn't functioning right for some people.

Some of these errors are likely related to interactions with different SFTP server protocol versions, their various implementations and extensions, and the module we use for SFTP client mode.

  • Unfortunately SFTP has a load of variations (v1-v6 + extensions) Table
  • The upstream SFTP module we use has been updated several times (and updated in NC as well) during these bug reports to address various issues and also deal with interactions with SFTP servers that - just as one example - do weird things like send attributes that aren't supported in the protocol version they've implemented(!)
  • It sounds like some holes have been plugged, but there remain a few more. The Issue's originally reported symptom (being able to download without it being blocked by an internal server error) seems to have been addressed. Unfortunately, there seem to be other some bugs and weird interactions still behind that, but we need to sort some things out first.

For SFTP bug reports it's important to report here:

  • the SFTP server implementation (and if not it's protocol version certainly the software version itself)
  • the full NC stack trace resulting from a sequence of steps that triggers a given error
  • the sequence of steps that triggers the given error in a repeatable manner
  • the exact NC version

It's also critical we:

  • take special care when we compare reports across different NC versions
  • distinguish between different errors (that may or may not have similar symptoms)

Now, unfortunately, I'm having a challenging reproducing the above issue. I'm testing against a Synology that uses OpenSSH and supports SFTPv3. And I see no issues like the above with NC26-current. Though that's not necessarily surprising given that it appears that @Teke-lili is using a completely different SSH server - Bitvise SSH it appears (what version though?).

It would be nice to consolidate #21429 and this issue, but that might be more challenging at this point since they both have a lot of history. So, instead, I'll post a similar comment as this one over there on that open Issue until it's clearer how related these remaining issues are.

@sachz19 Your issues may or may not be related. Without stack traces the only similarities are some of the symptoms. You stated:

All uploads through nextcloud clients fail if targeted to the sftp folder or its subfolders. Even downloading a file no larger than 10 MB from the sftp storage fail.

Either of those actions should generate the error state on-demand in NC in your environment from the sounds of it. So... can you perform either (or both) of these actions and then pull the stack trace(s) from your nextcloud.log (can also be accessed via Administration settings->Logging but make sure you use Copy raw and format the output as code here).

joshtrichards avatar Jun 12 '23 19:06 joshtrichards

Hello there, I encountered a quite similar error with external storage and SFTP. The fix in the "Additional Information" from @Teke-lili (remove special cases for SFTP.php) helped resolving my problem which was Nextcloud displaying empty (0KB) folders instead of the uploaded files (.jpg/.mov/.mp4). The files were indeed correct when looking into the local storage on the target machine and the user had full rights to view and/or edit the directory/files. When I was uploading new files there was a chance that the correct files with the corresponding sizes appeared but it was sporadic.

I run Nextcloud AIO with the v27.0.1 (AIO-Container 6.4.0) and SFTP through/to "standard" (no ext. container/package) SSH on an Unraid system: Error message: fopen(sftpread://mnt/disk1/cloud//Foto 10.07.2023 0930 7020.jpg): Failed to open stream: &quot;OCA\Files_External\Lib\Storage\SFTPReadStream::stream_open&quot; call failed at /var/www/html/apps/files_external/lib/Lib/Storage/SFTP.php#381

another error message in raw format: {"reqId":"vJh4gFnHv8tsTP9JBpuO","level":3,"time":"2023-08-01T06:24:20+00:00","remoteAddr":"XX.XXX.XXX.XX","user":"user,"app":"PHP","method":"GET","url":"/core/preview?fileId=36948&x=250&y=250","message":"fopen(sftpread://mnt/disk1/cloud//IMG_4863.MOV): Failed to open stream: &quot;OCA\\Files_External\\Lib\\Storage\\SFTPReadStream::stream_open&quot; call failed at /var/www/html/apps/files_external/lib/Lib/Storage/SFTP.php#381","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36","version":"27.0.1.2","data":{"app":"PHP"},"id":"64cad3a5802b8"}

DanielStandfest avatar Aug 02 '23 22:08 DanielStandfest