Connection reset by peer after 500 seconds - php

I have this strange problem when i run an import cronjob in made.
It processes a 1.5GB XML file containing about 400.000 products. The script works fine and would take multiple hours to complete, but after about 500/600 seconds i get the following email from the cron-deamon.
PHP Warning: file_get_contents(http://test.nl/admin/cron_index.php?route=module/EZImport&cron): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
in /home/test.nl/public_html/admin/controller/tool/EZImport_cron.php on line 8
Warning:
file_get_contents(http://test.nl/admin/cron_index.php?route=module/EZImport&cron):
failed to open stream: HTTP request failed! HTTP/1.1 500 Internal
Server Error in
/home/test.nl/public_html/admin/controller/tool/EZImport_cron.php
on line 8 bool(false)
My apache error-logs say:
[Fri Nov 02 09:43:39 2012] [warn] [client 176.9..174] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Fri Nov 02 09:43:39 2012] [error] [client 176.9..174] Premature end of script headers: cron_index.php
This is the cron file called by the cronjob
require_once('../../config.php');
$opts = array('http' =>
array('timeout' => 36000)
);
$context = stream_context_create($opts);
$url = HTTP_SERVER."cron_index.php?route=module/cronMod&cron";
$result = file_get_contents($url, false, $context);
var_dump($result);
die();
I need to run this cron via file_get_contents
Environment:
DEBIAN,
OpenCart
The max execution time in webmin (php config) is set to 36000 seconds.

processes a 1.5GB XML file
Erk, this is a bit silly - you need a minimum of 2 passes to verify the document is well formed and there's lot's of scope for bad things to happen.
The max execution time in webmin (php config) is set to 36000 seconds
For which end?
You also need to configure the timeout for the webserver and every other component in the chain between client and server, however trying to transfer a 1.5Gb file over HTTP is just silly - you might get it to work - but it's not the right way to solve the problem. Break it up into more manageable chunks.

Try using set_time_limit(0) in the script or change the time limit in php.ini

Related

fail to open file in laravel.The localhost page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500

When I try to run my project, I am getting this error in terminal.
[Fri Mar 30 14:36:23 2018] PHP Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Fri Mar 30 14:36:23 2018] PHP Fatal error: Unknown: Failed opening required '/var/www/html/imporeexcel/public/server.php' (include_path='.:/usr/share/php') in Unknown on line 0
I confirmed the issue, it seems a bug in laravel 5.6.12 installer. It deletes the server.php upon the first artisan serve.
A temporary solution will be to create another project then copy that newly created server.php this will solve it.
EDIT:
If your anti-virus is avast, you need to add exception there, I have a response in GitHub that avast considers it as a threat.

ISPConfig 3 - mod_fcgid: error reading data from FastCGI server

I recently restored a server backup and now I get the following error trying to access any website (including the ISPConfig admin interface):
mod_fcgid: error reading data from FastCGI server
End of script output before headers: index.php
I have tried to set
opcache.enable = 0
in php.ini which seems to have worked for some, but I still get the same results.
I am using ISPCOnfig 3 on Centos 7 with php 5.4.16 and Apache/2.4.6

Server/websites very slow loading

I have a server for 5 month now with Debian 7 Wheezy and cpanel virtual/webmin installed. Never had any problems except a week ago.
I did not do any changes on the server. The problem is as follows:
The first time when I checked the websites a week ago i received the DAtabase error 500 connection on every website i visited on the server.
I then checked status of server and MySQL was down. So i put this up and installed all updates in virtualmin and then restarted. All was working fine, until 10 minutes later. The website became very slow.
When I checked error log i got the following:
[warn] [client ] mod_fcgid: read data timeout in 40 seconds []
[error] [client ] Premature end of script headers: xmlrpc.php
I then changed FcgidConnectTimeout=600 to 9999 for /etc/apache2/mods-enabled/cfgid.conf. Again i did a restart and all was working fast again. ten minutes later same issue. Sites are loading very very slow.Sometimes more then a couple of minutes.
I checked error log again and i found the following error:
[warn] [client ] mod_fcgid: can't apply process slot for /home/fcgi-bin/

Symfony2 : site stop working afer clear:cache

I'm updating a symfony2 website, afeter each update in controller or twig file I run "php app/console cache:clear", the website stop working for 5 minutes then it works again. After un very little update, I cleared the cache and the site don't want to run anymore, I have 500 Internal Server Error, there are no entry in symfony's log file, but here what I found in php log :
[Thu Sep 24 08:10:05 2015] [error] [client 1.2.3.4] FastCGI: server "/run/fcgi-bin/www.mysite.com:80.fcgi" stderr: PHP message: PHP Warning: require_once(/var/www/mysite.com/app/cache/prod/jms_diextra/doctrine/EntityManager_5602df03afff5.php): failed to open stream: No such file or directory in /var/www/mysite.com/app/cache/prod/appProdProjectContainer.php on line 279
[Thu Sep 24 08:10:05 2015] [error] [client 1.2.3.4] FastCGI: server "/run/fcgi-bin/www.mysite.com:80.fcgi" stderr: PHP message: PHP Fatal error: require_once(): Failed opening required '/var/www/mysite.com/app/cache/prod/jms_diextra/doctrine/EntityManager_5602df03afff5.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/mysite.com/app/cache/prod/appProdProjectContainer.php on line 279
It seems to be entity issue, but I'm sure I have no entity updates. I even tried to roll back by uploading all original files but no way !
I don't understand :
why do I have to wait 5 minutes after each cache:clear ?
what does the log errors means ?
Thanks very much :)
It looks like a file permission problem on your cache directory (and/or your logs directory).
Try chmod -R 777 app/cache app/logs and tell us if you still have problems.
You can also check the umask trick in http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup that may help in your case.
I followed the instructions in URL posted by tchap.
I don't know why cache:clear throws the bug, but I tested this and it works :
manually delele the /app/cache/prod/ folder
run :
app/console cache:warmup

AWS Elastic Beanstalk - PHP script fails to execute after deploying new version

I am using AWS Elastic Beanstalk for PHP which manage 1 EC2 linux server with Apache web server.
When deploying a different version (zip file with all my php scripts) through the management console i sometimes run into a weird situation.
In some cases, even if i am deploying a version with exactly the same scripts which all worked before, some of them suddenly aren't working. When deploying another version again (still same scripts, same content), suddenly everything is working as normal.
Example of a problematic service :
<?php
// dynamically loads needed classes
function __autoload($class_name) {
include $class_name . '.php';
}
$response = new Response();
$response->data = array('platform_version' => Configuration::PLATFORM_VERSION);
die(json_encode($response));
?>
Normally, this script returns a json object. After changing nothing and deploying a version this scripts returns nothing. Is there a way to find if an error occurred?
BTW, i can see a call to the service in the application_access_log of Apache with return status 200.
EDIT:
After changing the error level on the web server i started to see interesting information in the application_error_log :
*[Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP Fatal error: require_once() [function.require-once]: Cannot redeclare class response in /var/www/html/InstallerLog.php on line 12
[Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP Stack trace:
[Mon Nov 05 17:19:44 2012] [error] [client 10.210.159.209] PHP 1. {main}() /var/www/html/InstallerLog.php:0*
Why am i getting this error?
I am using :
require_once 'Response.php';
In my script so this kind of error should not occur for my knowledge...
OK. So eventually it was pretty basic.
The error occurred because the class name i was using, "Response", was already in use in other place (not in my code, maybe in the SDK or something like that).
After changing the name to something less generic the error didn't happen again.
Just for play safe i have also added :
if(!class_exists('MyNewResponse'))
before creating the class.

Categories