jamhall / s3rver

A fake S3 server written in NodeJs
MIT License
571 stars 148 forks source link

Error: fopen(httpseek://): failed to open stream ... #713

Open parajbs opened 3 years ago

parajbs commented 3 years ago

I test Nextcloud21 with s3rver version 2.2.6 - 2.2.9, there is no error message (see below), when opening and editing (streaming) files!

From version 3.0.0 - 3.6.1-master the error message appears when opening and editing:

Error: fopen(httpseek://): failed to open stream: "OC\Files\Stream\SeekableHttpStream::stream_open" call failed at /var/www/html/lib/private/Files/Stream/SeekableHttpStream.php#67

When I download the file via Nextcloud, the error from above comes first and then the error message:

Sabre\DAV\Exception\ServiceUnavailable: Could not open file

I looked through both codes of the different versions, but haven't found the bug yet! In the older version of s3rver the open / streaming / (seeking) and downloading works OK! But in the new version I have problems with understanding koa, so it is difficult to find and correct errors!

Can any of you help!

It is important to fix the bugs in the newer version!

leontastic commented 3 years ago

@parajbs It would help greatly if you could provide a minimal test case/repository demonstrating the issue. It's hard to debug any issues without one.

Based on the details you provided, it sounds like your issue might be related to the PHP you're running. None of the error messages you provided originate from s3rver.

parajbs commented 3 years ago

@leontastisch I have different test-s3rver setups and Nextcloud21 as client:

CLIENT (Nextcloud21)

############################################

  1. Web host with nodejs s3rver 2.2.6 :
    • Nginx-proxy -> Apache (php v7.3.27/PhP executed as FastCGI application) -> node (8.16.0/development) -> s3rver (2.2.6)

s3rver_index.js: ############ const os = require('os'); const fs = require('fs'); const S3rver = require('s3rver');

const corsConfig = require.resolve('./cors.xml'); const websiteConfig = require.resolve('./example/website-test0.xml');

const instance = new S3rver({ port: 80, hostname: 'S3domain1', silent: false, directory: './tmp/s3rver', allowMismatchedSignatures: false, vhostBuckets: false, configureBuckets: [ { name: 'test-bucket', }, ], }).run((err, { address, port } = {}) => { if (err) { console.error(err); } else { console.log('now listening at address %s and port %d', address, port); } });

cors.xml: #######

* PUT POST DELETE HEAD OPTIONS 3000 Authorization Content-Type

curl -I https: //S3domain1/test-bucket

HTTP/1.1 200 OK Server: nginx Date: Sat, 17 Apr 2021 17:10:44 GMT Content-Type: application/xml; charset=utf-8 Content-Length: 1180 Connection: keep-alive Vary: Accept-Encoding X-Powered-By: Phusion Passenger ETag: W/"49c-iJoFrZkzQfUk0tvPpwezb+FwNw0" Status: 200 OK

NO Error (Client Netxcloud21): ####### no Error! I can open and edit a file and save and upload! check: The file is ok (have text) via "CloudBerry Explorrer"! When I open the file I can see the text! check: The file is ok (have text) via "CloudBerry Explorrer"! Nextcloud21 can open the POST stream from S3rver is OK! (I can see text)

apache2-log(Client Netxcloud21 ): ########## 207 PROPFIND /remote.php/dav/files/exadmin/mys32/tfff.md HTTP/1.0 200 PUT /index.php/apps/text/session/create HTTP/1.0 200 POST /index.php/apps/text/session/fetch HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/push HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/close HTTP/1.0

apache2-log S3rver (2.2.6): ############### 200 HEAD /test-bucket HTTP/1.0 200 HEAD /test-bucket/tfff.md HTTP/1.0 200 GET /test-bucket?prefix=tfff.md&max-keys=1&delimiter=%2F&encoding-type=url HTTP/1.0 206 GET /test-bucket/tfff.md HTTP/1.0 200 POST /test-bucket/tfff.md?uploads HTTP/1.0 200 PUT /test-bucket/tfff.md?partNumber=1&uploadId=26b42190aba8be357529dd8ffa13007e HTTP/1.0 200 POST /test-bucket/tfff.md?uploadId=26b42190aba8be357529dd8ffa13007e HTTP/1.0 200 HEAD /test-bucket/tfff.md HTTP/1.0 200 GET /test-bucket?prefix=tfff.md&max-keys=1&delimiter=%2F&encoding-type=url HTTP/1.0

##############################################################

  1. Web host with nodejs s3rver 3.61_main:
    • Nginx-proxy -> Apache (php v7.3.27/PhP executed as FastCGI application) -> node (10.16.0/development) -> s3rver (github.com/jamhall/s3rver branche=main)

s3rver_index.js: ########### const os = require('os'); const fs = require('fs'); const S3rver = require('./lib/s3rver'); const { fromEvent } = require('rxjs'); const { filter } = require('rxjs/operators');

const corsConfig = require.resolve('./cors.xml'); const websiteConfig = require.resolve('./example/website-test0.xml');

const instance = new S3rver({ port: 80, address: 'S3domain2', silent: false, directory: './tmp/s3rver', allowMismatchedSignatures: true, vhostBuckets: false, configureBuckets: [ { name: 'cweb', configs: [fs.readFileSync(corsConfig), fs.readFileSync(websiteConfig)], }, { name: 'test-bucket', }, ], }).run((err, { address, port } = {}) => { if (err) { console.error(err); } else { console.log('now listening at address %s and port %d', address, port); } });

const s3Events = fromEvent(instance, 'event'); s3Events.subscribe((event) => console.log(event)); s3Events .pipe(filter((event) => event.Records[0].eventName == 'ObjectCreated:Copy')) .subscribe((event) => console.log(event));

cors.xml:

* PUT POST DELETE HEAD 3000 Authorization Content-Type *

curl -I https://S3domain2/test-bucket

HTTP / 1.1 200 OK Server: nginx Date: Sat, Apr 17, 2021 16:11:10 GMT Content-Type: application/xml Content-Length: 4081 Connection: keep-alive Vary: Accept-Encoding X-Powered-By: Phusion Passenger Status: 200 OK

Error (Client Netxcloud21):

see post 1 Error: fopen(httpseek://): failed to open stream: "OC\Files\Stream\SeekableHttpStream::stream_open" call failed at /var/www/html/lib/private/Files/Stream/SeekableHttpStream.php#67

check: The file is ok (have text) via "CloudBerry Explorrer"! The file open ONLY as blank document (I can not see any text)! Then I edit (write new text) the file and save aund upload ! check: The file is ok (have the new text) via "CloudBerry Explorrer"! When I reopen the document, it is ONLY a blank document , but I can NOT see the new text from the check! If I just close the blank document! check: The file is ok (have the new text) via "CloudBerry Explorrer"!

I think the error is here, but I'm not quite sure how to fix it: Nextcloud21 POST stream from S3rver is DEFFECT! (can NOT any text)!

apache2-log(Client Netxcloud21 ) ########## 207 PROPFIND /remote.php/dav/files/exadmin/mys3261/gfgfgdd.md HTTP/1.0 200 PUT /index.php/apps/text/session/create HTTP/1.0 200 POST /index.php/apps/text/session/fetch HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/push HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/sync HTTP/1.0 200 POST /index.php/apps/text/session/close HTTP/1.0

apache2-log S3rver (3.6.2_main): ############### 200 HEAD /test-bucket HTTP/1.0 200 HEAD /test-bucket/gfgfgdd.md HTTP/1.0 200 GET /test-bucket?prefix=gfgfgdd.md&max-keys=1&delimiter=%2F&encoding-type=url HTTP/1.0 200 GET /test-bucket/gfgfgdd.md HTTP/1.0 200 POST /test-bucket/gfgfgdd.md?uploads HTTP/1.0 200 PUT /test-bucket/gfgfgdd.md?partNumber=1&uploadId=6420e6a07e88205c3b00783eba2cb5cd HTTP/1.0 200 POST /test-bucket/gfgfgdd.md?uploadId=6420e6a07e88205c3b00783eba2cb5cd HTTP/1.0 200 HEAD /test-bucket/gfgfgdd.md HTTP/1.0 200 GET /test-bucket?prefix=gfgfgdd.md&max-keys=1&delimiter=%2F&encoding-type=url HTTP/1.0

I think the error is here, but I'm not quite sure how to fix it: Nextcloud21 POST stream from S3rver is DEFFECT! (can NOT any text)!

leontastic commented 3 years ago

@parajbs I would really like to understand what your issue is, but I'm having a hard time interpreting what exactly you are trying to do which causes the regression to appear, and exactly what the regression is. If you'd like help on this, please provide brief answers to these questions:

  1. What are you trying to do with S3rver?
  2. What is the HTTP request you are sending to S3rver that is causing the error?
  3. What error message do you receive from S3rver when the request errors?
  4. What is the response you are expecting from S3rver?
  5. How is your S3rver instance configured?

Please exclude any references to your own application or other software. I don't know anything about Nextcloud21 or Cloudberry Explorer so I can't really interpret output from these applications. Dumping logs from these applications is very confusing and unhelpful. The best way you can ask for help is by creating a new repository with a Minimal Reproducible Example of your problem that I can test on my own machine with git clone and npm install && npm start.

parajbs commented 3 years ago

Sorry that it took so long, but I had to find my way around the S3rver code first! I had to extend the logger.js so that the complete "console-log" from S3RVER is written into a logfile!

I'm not sure how the questions can be answered!

  1. I try to use php (nextcloud21) to display the file.txt (the text "hello world" is in the file) in the browser, which is on the S3RVER (version 3.6.1) in the "test-bucket" bucket !

Problem: file.txt is opened in the browser, but no text "hello world" is displayed!

When I test the same process with S3rver (version 2.2.6) / minio-server or filebase.com, file.txt is opened and the text "hello world" can be seen! So the client (Nextcloud21 / aws-sdk-php 1.7.1) is OK!

  1. I have no idea which HTTP request Nextcloud21-client (aws-sdk-php 1.7.1) is sent to the S3rver when opening file.txt!

[The error message from post1 means that Nextcloud wants to create a preview of the file.txt, but cannot open the file.txt or does not understand it!]

  1. Don't get an error message on the S3rver! Definitely didn't see any!

  2. I expect the S3rver to display the content of file.txt in the browser, but the content is not displayed in the browser!

  3. I'm not sure how to answer the questions, since all the information was already in the previous posts!