Timeout in FileAdapter or Empty response from server when trying to upload a small size file
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 outfor the GridStoreAdapterConnection timed out after 120000msfor 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.
With S3Adapter:
Connection timed out after 120000ms TimeoutError: Connection timed out after 120000ms
at ClientRequest.
You need to set the maxUploadSize, it's 20Mb by default https://github.com/parse-community/parse-server/blob/master/src/ParseServer.js#L122
@flovilmart So why can't I upload a 19MB file
@flovilmart I just set the maxUploadSize to '30mb' and result is exactly the same.
ANd if you bump it even more?
@flovilmart Just set '100mb' and nothing changed
I'll have a look
Are you noticing the issue only locally? What are the logs when running with VERBOSE=1?
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.
@cjosepha Hi can you pls share how you did this i'm also facing the same issue, i cannot upload large files
@Sarun1001 basically I upgraded to higher Parse version and also edited my nginx configuration to increase the request body maximum size