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

500 error on page media listing #730

Closed
ghost opened this issue Aug 5, 2016 · 3 comments
Closed

500 error on page media listing #730

ghost opened this issue Aug 5, 2016 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Aug 5, 2016

Hi,

I use Grav as CMS for a one-page website. I have a working Grav installation setup locally (local amp-stack) and on a remote server. Both have PHP 5.6+ installed and both have upload_max_filesize and post_max_size set to 128MB.

However, when I try to upload a big image of 2MB size on the remote server using page media in the admin section, the upload itself succeeds, but when I try to save the page (and everytime when I load this page) I get an error:

"Fetch Failed: Unexpected end of JSON input: Unexpected token < in JSON at position 0"

This only happens on the remote server. When I do this with the same image on my localhost, it works fine.

I've been searching with the inspector what exactly goes wrong, and found that a 500 server error is thrown when it tries to load this file:
.../grav/admin/media/home/_mypage.json/task:listmedia/admin-nonce:c0c8 aa0433082ff254452d221461986c

Therefore I went looking into my server log what might cause this error and found this:

[Thu Aug 04 16:03:58 2016] [error] [client ] (104)Connection reset by peer: FastCGI: comm with server " /var/www/cgi-bin/php5-www.bringme.com-fcgi" aborted: read failed, referer: http://bringme.com/grav/admin
[Thu Aug 04 16:03:58 2016] [error] [client ] FastCGI: incomplete headers (0 bytes) received from server "/var/www/cgi-bin/php5-www.bringme.com-fcgi", referer: http://bringme.com/grav/admin

I don't really know what this means. Does it might have something to do with a connection time-out?

Again, this only happens with the big image file. When I use smaller images, the error does not occur. So I don't think permissions are wrong. Is there somewhere a max filesize defined? Do I have to change something on my remote server to make this work?

The big image that I used can be found here.
If it helps, you can check phpinfo on the remote server here.

@flaviocopes
Copy link
Contributor

Mmm I replicated it once locally, using the image provided.
But the next times I tried re-uploading the image, it worked fine. Need to find a way to replicate it consistently.

@flaviocopes flaviocopes added the bug label Aug 5, 2016
@ghost
Copy link
Author

ghost commented Aug 8, 2016

I have found out more about this issue:

First of all, the problem seems not related to the size of the image (in Megabytes), but it has to do with the image dimensions (pixels), apparently being too large for php memory to handle.

On my personal server (LiteSpeed, 96M php memory limit), the image error appeared as well with the image I posted. By uploading different kinds of images, I managed to find that images up to 9MB in size kept on working without problems, as long as they were smaller than 4300 x 4300 pixels in size. Whenever I used an image bigger than 4300 x 4300 pixels, even if it was 1MB in size or less, it failed. Using progressive or optimized JPG's did not change anything.

Meanwhile, I contacted the hosting company from the above mentioned server (FastCGI, 128 php memory limit), they managed to find out there was an error occuring somewhere in the php memory, and they managed to resolve it by disabling opcache.

Therefore, I tried disabling opcache as well on my personal server (LiteSpeed), which did not change anything. I did however, increase my php memory limit up to 128 mb. This did the trick! When increasing the php memory limit, I am able to upload bigger images (in pixel size). I'm stupid not checking this earlier. :)

To summarize things: I think it depends on the server technology used. When using LiteSpeed (I would recommend this), increasing the php memory limit should do the trick. You can leave opcache and apcu enabled to speed things up, it does not affect this issue.

@flaviocopes
Copy link
Contributor

Ok, closing this then, hopefully it's still searchable in the issues if someone else runs into this.

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

No branches or pull requests

1 participant