Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout in FileAdapter or Empty response from server when trying to upload a small size file #3830

Closed
cjosepha opened this issue May 18, 2017 · 10 comments

Comments

@cjosepha
Copy link

Issue Description

I try to save a 19MB file via the rest api with Curl. Sometimes Curl indicates that the server response is empty, and sometimes the server respond with code 130 "Could not store file." This behavior is totally unpredictable and seems due to a timeout error in the FileAdapter.
I tried with both the S3Adapter and the default GridStoreAdapter and they produce the same behavior that I've just mentioned.

When response is {"code":130,"error":"Could not store file."} the server logs indicates a timeout in the FileAdapter:

  • connection 6 to ... timed out for the GridStoreAdapter
  • Connection timed out after 120000ms for the S3Adapter

I think this unpredictable behavior is a bug that should be fixed to save debugging time as the first responses was empty in my cases, so I didn't know there was a timeout issue.
Also note that sometimes, the timeout error log on the server can appear after (a few minutes) the Curl command returns and indicates that response is empty.

Can anyone provide me some answers about this :

  • Should not the return code always be 124?
  • Is there a way to avoid the timeout for file saving operations? If not, should not one be provided?

Steps to reproduce

  • My internet connection upload speed is 0.3Mbps
  • File to upload is a text file of 19MB I created for test purpose
  • Curl command:
    curl -X POST
    -H "X-Parse-Application-Id: APP_ID"
    -H "X-Parse-Master-Key: MASTER_KEY"
    -H "Content-Type: text/plain"
    -d "@file.txt"
    http://localhost:1337/parse/files/file.txt

Expected Results

File successfully created as the file is under the 20MB limit.

Actual Outcome

Either an empty response or code 130 "Could not store file.", randomly.

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.3.7, 2.3.8, 2.4.0
    • Operating System: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database

    • MongoDB version: 3.0.10
    • Storage engine: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): AWS

Logs/Trace

With GridStoreAdapter:
connection 6 to ... timed out MongoError: connection 6 to ... timed out
at Function.MongoError.create (/Users/.../dist/node_modules/mongodb-core/lib/error.js:29:11)
at Socket. (/Users/.../dist/node_modules/mongodb-core/lib/connection/connection.js:188:20)
at Socket.g (events.js:291:16)
at emitNone (events.js:86:13)
at Socket.emit (events.js:185:7)
at Socket._onTimeout (net.js:339:8)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)

With S3Adapter:
Connection timed out after 120000ms TimeoutError: Connection timed out after 120000ms
at ClientRequest. (/Users/.../dist/node_modules/aws-sdk/lib/http/node.js:83:34)
at ClientRequest.g (events.js:291:16)
at emitNone (events.js:86:13)
at ClientRequest.emit (events.js:185:7)
at TLSSocket.emitTimeout (_http_client.js:626:10)
at TLSSocket.g (events.js:291:16)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket.Socket._onTimeout (net.js:339:8)
at ontimeout (timers.js:365:14)

@flovilmart
Copy link
Contributor

You need to set the maxUploadSize, it's 20Mb by default https://github.com/parse-community/parse-server/blob/master/src/ParseServer.js#L122

@cjosepha
Copy link
Author

@flovilmart So why can't I upload a 19MB file

@cjosepha
Copy link
Author

@flovilmart I just set the maxUploadSize to '30mb' and result is exactly the same.

@flovilmart flovilmart reopened this May 18, 2017
@flovilmart
Copy link
Contributor

ANd if you bump it even more?

@cjosepha
Copy link
Author

@flovilmart Just set '100mb' and nothing changed

@cjosepha cjosepha changed the title Timeout in FileAdapter when trying to upload a small size file Timeout in FileAdapter or Empty response from server when trying to upload a small size file May 18, 2017
@flovilmart
Copy link
Contributor

I'll have a look

@flovilmart
Copy link
Contributor

Are you noticing the issue only locally? What are the logs when running with VERBOSE=1?

@cjosepha
Copy link
Author

I don't remember if this was the case at the time I created the issue. But now, with parse-server 2.6.3 on a remote server, there is no more timeout.
This allowed me to go further and to discover I had to increase the http request body size in the server configuration.
Now larger files can be uploaded.

@Sarun1001
Copy link

@cjosepha Hi can you pls share how you did this i'm also facing the same issue, i cannot upload large files

@cjosepha
Copy link
Author

cjosepha commented Jan 9, 2023

@Sarun1001 basically I upgraded to higher Parse version and also edited my nginx configuration to increase the request body maximum size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants