Occasional getimagesize time-outs

I’ve been using a cgi-based image creation script for some time and making use of getimagesize() for the dimensions.

When I started to use Cloudflare, I occasionally see time-out and handshake warnings. There are thousands of such images being served per day with no problems, but about 5 or so fall over.

Any advice would be appreciated.

PHP Warning: getimagesize([cgi image]): failed to open stream: HTTP request failed! HTTP/1.1 504 Gateway Time-out in [path info] on line 77
PHP Warning: getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure in [path info] on line 77

I presume you are talking about calling getimagesize() with a URL as parameter, right?

Where are these images located? You’d need to post more details about that setup in order to get anything close to a meaningful response :slight_smile:

what operating system and version of the server ? centos/ubuntu ?

do you have SSH access to your server ? can post output for these commands

curl -V
php -v
php --ri curl
php --ri openssl

Thank you for your replies.

@sandro: Yes, getimagesize() uses a URL parameter and the images are located on the same server as the calling script.

@eva2000: As requested:

Mod_Pagespeed in enabled in EA via the plBake script.
root@host [3239 04:51:12 ~]# curl -V
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.34 zlib/1.2.7 libidn/1.28 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets
root@host [3240 04:51:30 ~]# php -v
PHP 5.5.38 (cli) (built: May 24 2017 08:47:39)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.1.1, Copyright (c) 2002-2016, by ionCube Ltd.
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2014, by Zend Technologies
root@host [3241 04:51:41 ~]# php --ri curl


cURL support => enabled
cURL Information => 7.38.0
Age => 3
AsynchDNS => No
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
SSL => Yes
SSPI => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, pop3, pop3s, rtsp, smtp, smtps, telnet, tftp
Host => x86_64-unknown-linux-gnu
SSL Version => OpenSSL/1.0.1e
ZLib Version => 1.2.7
root@host [3242 04:51:56 ~]# php --ri openssl


OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.1e-fips 11 Feb 2013
OpenSSL Header Version => OpenSSL 1.0.1e-fips 11 Feb 2013
root@host [3243 04:52:11 ~]# php-config
Usage: /usr/local/bin/php-config [OPTION]
–prefix [/usr/local]
–includes [-I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib]
–ldflags [ -L/opt/xml2/lib -L/opt/pcre/lib64 -L/opt/curlssl/lib -L/opt/curlssl//lib64 -L/opt/php_with_imap_client//lib64 -L/opt/libmcrypt//lib64 -L/opt/mm//lib64 -L/opt/tidy//lib64 -L/opt/xslt/lib -L/opt/xslt//lib64]
–libs [-lcrypt -lc-client -lcrypto -lssl -lcrypto -lz -lexslt -lexpat -lexpat -lexpat -ltidy -lresolv -lcrypt -lmm -laspell -lpspell -lmcrypt -lltdl -lstdc++ -lcrypto -lssl -lcrypto -lcrypt -lpam -lX11 -lXpm -lpng -lz -ljpeg -lcrypto -lssl -lcrypto -lcurl -lbz2 -lz -lpcre -lcrypto -lssl -lcrypto -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lcurl -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -ldl -lfreetype -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -ldl -lm -licui18n -licuuc -licudata -ldl -lm -licuio -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxslt -lxml2 -lz -ldl -lm -lcrypt ]
–extension-dir [/usr/local/lib/php/extensions/no-debug-non-zts-20121212]
–include-dir [/usr/local/include/php]
–man-dir [/usr/local/php/man]
–php-binary [/usr/local/bin/php]
–php-sapis [ cli litespeed cgi]
–configure-options [–disable-posix --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-gd-native-ttf --enable-intl --enable-libxml --enable-mbstring --enable-opcache --enable-pdo=shared --enable-soap --enable-sockets --enable-wddx --enable-zip --prefix=/usr/local --with-bz2 --with-curl=/opt/curlssl/ --with-freetype-dir=/usr --with-gd --with-gettext --with-icu-dir=/usr --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-kerberos --with-libdir=lib64 --with-libexpat-dir=/usr --with-libxml-dir=/opt/xml2 --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mm=/opt/mm/ --with-mysql --with-mysqli --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pic --with-png-dir=/usr --with-pspell --with-tidy=/opt/tidy/ --with-xmlrpc --with-xpm-dir=/usr --with-xsl=/opt/xslt/ --with-zlib --with-zlib-dir=/usr --with-litespeed]
–version [5.5.38]
–vernum [50538]
root@host [3244 04:52:22 ~]#

In that case I’d strongly recommend to dump the URL approach and access the files directly in the filesystem.

@sandro: Problem is, they are cgi images created on the fly from user input. They can only be triggered (created) by a https call (I believe). Using $_SERVER['DOCUMENT_ROOT']."/cgi-bin/[ script here ] as parameter caused a 500 error.

I understand the issue, but that would simply be a rewrite of either script (the one generating the images and/or the one checking the size). Using an HTTP call for locally stored/generated images usually is just an open invitation for such issues.

I dont know your setup, but the best approach could be to simply generate the images in the place where you are checking their size right now.

  1. Ensure all yum packages on your system are up to date yum -y update seems your are using centos/rhel system but PHP reports OpenSSL 1.0.1e while lastest system OpenSSL for OS is 1.0.2k which suggests maybe your are behind on system updates?
  2. Update to PHP 5.6.38 at least and see

I ended up abandoning the cgi script and I’m now creating the images using PHP. I can thus reliably determine the image sizes without a http call, so all is sweet now.

Thanks for your help.

This topic was automatically closed after 31 days. New replies are no longer allowed.