CodeIgniter Forums
[MAYBE SOLVED] HTTPS site losing PHP connection overnight! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: [MAYBE SOLVED] HTTPS site losing PHP connection overnight! (/showthread.php?tid=78716)



[MAYBE SOLVED] HTTPS site losing PHP connection overnight! - John_Betong - 03-01-2021

I have an Ubuntu VPS server with over a dozen sites and recently added a new free domain with CI4. The site still opens a index.html but PHP is not working?

For the past couple of days I have had to reinstall the Certbot certificate and that cured the problem. 

Now the PHP is giving the following error report:


This site can’t be reached
MyNewSite.com unexpectedly closed the connection.
Try:
  • Checking the connection
[color=var(--error-code-color)]ERR_CONNECTION_CLOSED[/color]


Any suggestions as to where I should start looking for the problem?


RE: HTTPS site losing PHP connection overnight! - John_Betong - 03-04-2021

I think I have found the problem now that I have added declare(strict_types=1); to every system PHP file:

Quote:( ! ) Fatal error: Uncaught TypeError: filter_var(): Argument #3 ($options) must be of type array|int, null given in /var/www/ci4-strict.tk/system/HTTP/RequestTrait.php on line 341


The following KLUDGE fixes the problem:

File: /system/HTTP/RequestTrait.php on line 341
PHP Code:
# KLUDGE - 2021-03-05
   $flags NULL ?: 0;

  return 
filter_var($value$filter$flags);
}
// public function fetchGlobal($method, $index = null, $filter = null, $flags = null) 

Usually the site has previously gone down overnight and I will check again tomorrow to ensure the KLUDGE cures the problem... watch this space Smile


RE: [MAYBE SOLVED] HTTPS site losing PHP connection overnight! - iRedds - 03-05-2021

In the latest version CI 4.1.1 line 341 //--------------------------------------------------------------------

declare(strict_types=1); - Strict type matching. Without this, null will not throw errors.


RE: [MAYBE SOLVED] HTTPS site losing PHP connection overnight! - John_Betong - 03-05-2021

@iReddis,
> declare(strict_types=1); - Strict type matching. Without this, null will not throw errors.

That was why I added strict_types. The site was going down and there were no errors being reported!

Where should I have started looking for problems without any errors logged?

Update:
The site did not go down last night I am delighted to say Smile


RE: [MAYBE SOLVED] HTTPS site losing PHP connection overnight! - iRedds - 03-05-2021

I may be wrong, but it seems to me that you have a problem on the path from the browser to the server. But not including the framework.
Set environment as development in the .env file.
See server logs.


RE: [MAYBE SOLVED] HTTPS site losing PHP connection overnight! - John_Betong - 03-05-2021

@iReddis,
Quote:Set environment as development in the .env file.
See server logs.

I set the online .env file development and managed to get the error_logs to render...

I prefer using strict_types=1 and will raise some Pull Requests where necessary.


RE: [MAYBE SOLVED] HTTPS site losing PHP connection overnight! - John_Betong - 03-12-2021

(03-05-2021, 06:41 PM)iRedds Wrote: I may be wrong, but it seems to me that you have a problem on the path from the browser to the server. But not including the framework.
Set environment as development in the .env file.
See server logs.

The server was still going down overnight but at least errors were reported thanks to strict_types=1;

After well over a week I bit the bullet and purged apache2 and a2dismod php7.4... then reinstalled apache2 and php8.0. It took a while but eventually after installing a2enmod missing apache2 modules and using certbot to reinstall about sixteen domains the new domain was still going down overnight!!!!!

Fortunately I had a spare domain (which is seldom used) and swapped all the content from the new domain to the spare domain and the new domain has not gone down!!!