Advertisement:

Author Topic: HTTP 502 When Retrieving Attached Images  (Read 589 times)

Offline sah62

  • Jr. Member
  • **
  • Posts: 102
HTTP 502 When Retrieving Attached Images
« on: January 23, 2020, 09:45:23 AM »
Every so often I see one of these errors in my web server log when a user is viewing a topic that includes image attachments:

Code: [Select]
X.X.X.X - - [23/Jan/2020:09:33:23 -0500] "GET /forum/index.php?action=dlattach;topic=27090.0;attach=19466;image HTTP/1.1" 502 182 "https://www.mysite.org/forum/index.php?topic=27090.msg182574;topicseen" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0"

It seems to happen more often when the topic includes multiple large attachments. In the case above, the topic had three images of sizes 3631.5 kB, 5732.19 kB, and 5918.2 kB, though of course the displayed thumbnails are much smaller. This looks like an "out of resources" issue, but I'm not sure which PHP configuration parameter I would need to adjust, or if it even make sense to try.

I've tried placing size limits on attachments. My user community is pretty clueless when it comes to re-sizing images manually, and I always end up with "I can't attach images" complaints when the limits are in place. Is there a way to get SMF to automatically re-size uploaded images?

Offline @rjen

  • Full Member
  • ***
  • Posts: 550
  • Gender: Male
    • FJR-club Nederland
Running SMF 2.0 with Tinyportal 1.6.5 at www.fjr-club.nl
Testing SMF 2.1 RC2 with Tinyportal at http://test2.fjr-club.nl/

Offline sah62

  • Jr. Member
  • **
  • Posts: 102
Re: HTTP 502 When Retrieving Attached Images
« Reply #2 on: January 28, 2020, 10:43:24 AM »
Image resizing hasn't eliminated the crash problem for me. I still see the occasional crash in my logs when processing image attachments. PHP-FPM log:

Code: [Select]
[28-Jan-2020 08:41:11] WARNING: [pool smf] child 18840 exited on signal 7 (SIGBUS - core dumped) after 205.327441 seconds from start
[28-Jan-2020 08:42:55] WARNING: [pool smf] child 5444 exited on signal 7 (SIGBUS - core dumped) after 1984.657430 seconds from start
[28-Jan-2020 08:44:54] WARNING: [pool smf] child 20837 exited on signal 7 (SIGBUS - core dumped) after 223.403533 seconds from start

Note that two of these pools crashed only a few minutes after they were started. Nginx log:

Code: [Select]
X.X.X.X - - [28/Jan/2020:08:41:11 -0500] "GET /forum/index.php?action=dlattach;topic=27106.0;attach=19514;image;ts=1580005456 HTTP/1.1" 502 182 "https://www.mysite.org/forum/index.php?topic=27106.0" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"
Y.Y.Y.Y - - [28/Jan/2020:08:42:55 -0500] "GET /forum/index.php?action=dlattach;topic=27106.0;attach=19520;image;ts=1580005519 HTTP/1.1" 502 182 "https://www.mysite.org/forum/index.php?topic=27106.msg182695" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; EIE10;ENUSWOL; rv:11.0) like Gecko"
Y.Y.Y.Y - - [28/Jan/2020:08:44:54 -0500] "GET /forum/index.php?action=dlattach;topic=27082.0;attach=19550;image;ts=1580087566 HTTP/1.1" 502 182 "https://www.mysite.org/forum/index.php?topic=27082.0" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; EIE10;ENUSWOL; rv:11.0) like Gecko"

Are there any PHP FPM configuration variables that need to be looked at? Right now I'm doing this:

Code: [Select]
memory_limit = 256M
opcache.memory_consumption=256


Offline sah62

  • Jr. Member
  • **
  • Posts: 102
Re: HTTP 502 When Retrieving Attached Images
« Reply #3 on: January 30, 2020, 07:43:59 AM »
In the absence of any other suggestions, I've been tweaking the value of pm.max_requests in my pool config file to respawn processes. I haven't seen any crashes for almost 24 hours now, so this might be a reasonable work-around. I still don't know if the crashes are an FPM issue, an SMF issue, or something else, but this seems to be working for me. An optimal value for anyone else will require experimentation to find the right number of requests.

Code: [Select]
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 25

Offline d3vcho();

  • Sempiterno
  • Lead Localizer
  • SMF Hero
  • *
  • Posts: 4,179
  • Gender: Male
    • frandominguez03 on GitHub
Re: HTTP 502 When Retrieving Attached Images
« Reply #4 on: January 30, 2020, 07:45:39 AM »
What version of SMF are you using? Do you have Image Proxy enabled?

"Greeting Death as an old friend, they departed this life as equals."

Offline sah62

  • Jr. Member
  • **
  • Posts: 102
Re: HTTP 502 When Retrieving Attached Images
« Reply #5 on: January 30, 2020, 08:30:07 AM »
What version of SMF are you using? Do you have Image Proxy enabled?

2.0.17, Image Proxy is not enabled.