0

So, I'm developing an nodejs app and the moment I put the application on an online server a problem happens that I can not solve. I am using nginx as a proxy for port 3000 which is where I have the nodejs app running.

In my app, I have a form where it is possible to upload an image, in localhost it always worked correctly, but now in the Google Cloud Platform instance it is not working.

Initially, 'Error 413 Request Entity Too Large' occurred, and I was able to solve this by adding the line

client_max_body_size 10M; 

to the nginx.conf configuration file.

The problem now is that when uploading an 8MB image, error 413 is not returned, but image uploading is not done either.

PS: I use the formidable to handle the data received from the server side.

(SOLVED)

Adding the line in the nginx configuration helped as well as increasing the server timeout (express). But the problem was related to the processing that was done in the images, in which they need more memory, than the memory that was free.

Rafael Veloso
  • 43
  • 1
  • 9
  • Try increasing the timeout of the express app. You can look over here (https://stackoverflow.com/questions/23925284/how-to-modify-the-nodejs-request-default-timeout-time) on how to do that. – Sookie Singh Jul 27 '18 at 15:47
  • I tested that right now @Er_sherlockian, and it actually changed one thing. The app after the upload is done, does a redirect to the homepage, and now I can see Chrome displaying a message like (Loading 50%,62%... ). But uploading the image still does not happen, because it don't appear in my database. – Rafael Veloso Jul 27 '18 at 16:08
  • Can you look into the cloud storage and see if it is reflecting there? May be you have an error in updating your database. – Sookie Singh Jul 27 '18 at 16:10
  • For now I'm still using the same database, which is housed in mLab @Er_sherlockian – Rafael Veloso Jul 27 '18 at 16:21
  • Is it working for a smaller file say 100kb? If yes, then can you check google cloud bucket where the image will get uploaded. – Sookie Singh Jul 27 '18 at 16:26
  • It's working on images up to 5 MB @Er_sherlockian – Rafael Veloso Jul 27 '18 at 16:29
  • Where does the file gets uploaded? Does it have any file-size limit? – Sookie Singh Jul 27 '18 at 16:35
  • I am using formidable to receive form content, and the maximum default size is 20MB. – Rafael Veloso Jul 27 '18 at 16:54
  • Formidable is the middleware. Are you storing the files on the server or any 3rd party such as Amazon s3 or Google cloud? Can you share the code where you are uploading? – Sookie Singh Jul 27 '18 at 17:14
  • I already found the problem. I'm using a Virtual Machine with only 0.6G of memory, and the image processor I'm using, Jimp, needs more than what's left to process the image. – Rafael Veloso Jul 27 '18 at 17:25
  • Wow!! Never thought of that. Good to learn something new! Kudos to you! – Sookie Singh Jul 27 '18 at 17:26
  • It took me a while! Better .catch() all the promises ahah And thanks to your answers @Er_sherlockian ;) – Rafael Veloso Jul 27 '18 at 17:30
  • Hahaha! No worries! Glad to be of any help! – Sookie Singh Jul 27 '18 at 17:33

0 Answers0