Getting and Error With an OK 200?

So, every time I run my code, I get this error:

OK
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.33 Server at xxxxxxxxx.com Port 80

… and here’s the last 4 errors from the error log:

173.48.xxx.xxx - - [05/Jun/2010:21:48:01 -0700] “GET xxxxxxxxx.com/mosaic/image_merge.php HTTP/1.1” 1 573 “-” “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0 ( .NET CLR 3.5.30729)”
173.48.xxx.xxx - - [05/Jun/2010:21:52:17 -0700] “GET xxxxxxxxx.com/mosaic/image_merge.php HTTP/1.1” 200 21540355 “-” “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0 ( .NET CLR 3.5.30729)”
173.48.xxx.xxx - - [05/Jun/2010:21:52:35 -0700] “GET xxxxxxxxx.com/mosaic/image_merge.php HTTP/1.1” 200 257478 “-” “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0 ( .NET CLR 3.5.30729)”
173.48.xxx.xxx - - [05/Jun/2010:22:02:52 -0700] “GET xxxxxxxxx.com/mosaic/image_merge.php HTTP/1.1” 1 573 “-” “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0 ( .NET CLR 3.5.30729)”

Because of the length of my code, I won’t post it all, but here’s the chunk where the error has appeared, then stopped the script:


$image_number = 0;
for($row = 0; $row < $rows; $row ++){	

	loader(60 + 30*($row / $rows));

	for($col = 0; $col < $columns; $col ++){		
		$copy_image = imagecreatefromjpeg($url_array[$image_number]);
		if(!$copy_image){
			$copy_image = imagecreatefromjpeg($url_array[$image_number - 1]);
		}
		$copy_image_width = imagesx($copy_image);
		$copy_image_height = imagesy($copy_image);
		if($copy_image_width > $copy_image_height){
			$copy_image_width = $copy_image_height;
		}else{
			$copy_image_height = $copy_image_width;
		}
		imagecopyresized($final_image, $copy_image, $size * $col, $size * $row, 0, 0, $size, $size, $copy_image_width, $copy_image_height);
		$image_number ++;
	}
}

Basically what this does is go through an array ($url_array) filled with URLs to images on another site, then scales, crops, and places them on my previously made $final_image into a kind of mosaic using imagecopyresized().

The final image is 66 by 66 images, so that’s ~4000 images. The overall process should take around 12 or so minutes, but it keeps getting stopped by this error somewhere around the 9 minute mark. I’ve also deduced that the error comes between the 45th and 55th row changing every time I run the script.

From these observations, I don’t think it’s a problem with any individual image I’m getting, but some kind of limit set. Because of this, I went over my php.ini file, that I had modified earlier to accommodate a high-resource script like this, here’s my php.ini:

max_execution_time = 10000
max_input_time = 10000
default_socket_timeout = 10000
memory_limit = 40000M
post_max_size = 10000M
file_uploads = On
upload_max_filesize = 10000M
output_buffering = 4000

I’m using PHP Version 5.2.8 and using shared linux hosting on Godaddy.

Sorry about the large amount of info and such, but I think that most if not all of it’s applicable. Tell me if any more information is needed :slight_smile:

So, any idea what’s going on? Thanks!

Also things to consider:
Are the images in question really large?
Do you perhaps want to imagedestroy your copy_image and free up the memory between cycles? (i’m not entirely sure if this could be the case, but it’s possible that simply overwriting your variable isnt freeing up the space, causing a massive load)

A few questions for you…

Have you tried capping the amount of images it processes to make sure the script completes correctly on a limited/specified amount?

Is there a particular image it fails on?

Do you have any control over the remote server? - the problem could actually be that end in that:

  • it could have an anti-hammering feature
  • it could have limited connections and you max them out
  • it could be so crap it just falls over

Can you loop through the script and do a file_get_contents for each image then output to a log file whether every connection was created correctly.

Can you log the responses you get from the remote server for each image?

Sounds like a pain in the butt of a problem if you don’t have control over both ends of the process!

MJ