-2

I use my personal website to host several images galleries, and for several months now, I've noticed that a lot of the thumbnail images appear broken and aren't loaded by the browser. This seems to be random: sometimes one page will load perfectly fine, other times the same page will appear completely broken.

screenshot of the problem

Obviously this is quite a catastrophic result for an image gallery...

This is not a problem with the images themselves: they've already been generated and are present on the server. In Firefox you can right-click the broken image and choose "reload image", and the image will appear immediately.

This is not a problem with the browser, OS or machine either: I tested it on various machines and with numerous browsers.

Upon inspection, the broken images correspond to 503 errors sent by the server (Service unavailable).

I checked the server logs for more details and found this kind of error for each "broken" image:

Rejected, too many connections from this host. (vhost:example.com:/sites/default/files/styles/[etc]) current: 27 limit: 20, referer: https://example.com/galeries

I contacted my hosting provider and their response was that "your site incorrectly handles PHP sessions. The connection is not closed between pages, and when this limit is reached, the site doesn't load any more."

I'm not sure where I can go from here...

Is this a know issue with Drupal 7? How can I fix it?

6
  • 1
    I think the support comment about PHP sessions is incorrect. The problem is that if the page causes multiple thumbnails to be generated at once that results in a corresponding number of PHP processes, and if too many, you hit their limit. There's not much you can do except to reduce the max number of images per page, or change hosting provider. Feb 12, 2020 at 11:37
  • Thanks, but the problem still occurs when the images are already generated, so I don't think that's it.
    – s427
    Feb 12, 2020 at 12:08
  • Or does Drupal rebuild those images from time to time, even when there's no need for it?
    – s427
    Feb 12, 2020 at 12:12
  • The images should not get rebuilt but a bad web server config might cause PHP to be invoked when not necessary. But there are cases where you might want them to be regenerated (theme tweak or the like) so I don't think this hosting is a good choice for your needs. Feb 12, 2020 at 13:02
  • Do you have some suggestions about what web server config specifically might cause this type of problem, so that I can check with them?
    – s427
    Feb 12, 2020 at 15:47

2 Answers 2

0

Images in files/styles are delivered directly via the web server, with no PHP code involved.

Change the hosting provider, it seems like they are not keeping up with browsers configured to use more simultaneous connections. Choose one providing HTTP/2, this protocol is supported by all modern browsers and doesn't have this issue.

2
  • Thanks. It seems they announced support for HTTP/2 back in 2017: news.infomaniak.com/en/a-glance-at-the-infomaniak-2017-roadmap Is there a way to check that it's actually used?
    – s427
    Feb 12, 2020 at 13:22
  • Never mind. I found several online tools for checking HTTP/2 support. They all confirm that it's indeed enabled on my site.
    – s427
    Feb 12, 2020 at 13:34
0

I have solved my problem, although I still don't understand exactly what caused it. It's probably a rather rare edge-case, but in case somebody runs into a similar situation, here's what I did.

One thing I didn't mention (because it didn't occur to me that it could be related to my problem) is that my site was configured so that Drupal was stored in a subfolder (/dp) while still being served from the root folder (thanks to some htaccess rewriting magic at root level).

Yesterday I decided to duplicate my site into another subfolder (/dev) on the same server, in the hope that I would then be able to try and disable various modules until I found which one caused my problem (without ruining my production site).

To my surprise, I was unable to cause the problem to appear on this new "dev" site, while the same problem was still easily triggered on my production site. At his point, the two sites were completely identical, except for one point: the production site had a "RewriteBase" rule activated in its .htaccess file, which I had to disable on the dev site:

RewriteBase /dp

So I made the guess that the problem was somehow related to this rule. I decided to change the way my site was configured and move Drupal directly in the root folder (as is usually the case). I then disabled the RewriteBase rule since it was not needed anymore.

That was enough to make the problem go away.

I'm not saying the rule is the direct or unique cause of the problem: I also had the exact same configuration on my localhost (Windows) machine, and I never encountered the same problem on it. So it's probably a combination of factors. I don't know more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.