I have a PHP 7 app that works well on all servers it's installed on except one. All servers are Windows (I believe server 2008 R2 and 2012). The problem is that on one of the servers, we keep getting two kinds of errors sporadically, seemingly randomly. One of the errors is
session_destroy(): Session object destruction failed
and the other is
PHP Fatal error: Uncaught exception 'ErrorException' with message 'Unknown: open(E:\tmp\sess_6qlo69vbii0qs65i4n47blafi3, O_RDWR) failed: Permission denied (13)' in Unknown:0
Every search I do on these errors go back to permissions, which makes sense aside from the fact that it's not happening every time, it's random. What am I missing here, could anything cause the permissions on the file to be different when the session gets created for some reason in certain situations? Or anything else that could possibly explain this behavior?
Related
Hope somebody can help here. We're running a MySQL Server (5.7.18-0ubuntu0.17.04.1), only a single application. A few clients connected pushing and pulling data from and into the database.
Sometimes, it goed all well for a long time... up to hours. Sometime, we're getting errors like
PHP Warning: mysqli::__construct(): (HY000/2002): Connection refused
or
PHP Warning: mysqli::query(): MySQL server has gone away
or
PHP Warning: mysqli::query(): Error reading result set's header
and
PHP Fatal error: Uncaught TypeError: Return value of mysqliConnection::escapeValue() must be of the type string, null returned
Errors above (At least the fatal errors), causes apache to exit with a 500-status-error. Not so good for our clients.
After searching, we found out all are mysql-related. Searching in the mysql-logs, gave us the mysqld got signal 11 ;. We're want to find out why this error / signal happens, but can't really find it. Tried a bunch of mysql-settings in my.cnf already, but doesn't seem to fix the issue.
See also these log-lines at pastbin: https://pastebin.com/GWDADudL
How can we find out what causes this error? Already used mysql.log to find out if it happens at a specific query, but seems to be random. Most tables are MyISAM, some InnoDB. Also had a MEMORY-table, but it's MyISAM now.
Help? Please? There seems to be something wrong, but what?
Having the same problem while installing the latest Prestashop on my server. So as #Agnes Tom has recommended, I changed the define.inc.php file and this is the error it´s showing up:
Warning: session_start(): open(/var/php_sessions/sess_b3c24487f16e9dcc7ebe9b0897bee69f, O_RDWR) failed: No such file or directory (2)
in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/install/classes/session.php on line 47 Notice: Use of undefined constant _NEW_COOKIE_KEY_ - assumed '_NEW_COOKIE_KEY_'
in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/classes/Cookie.php on line 79 Fatal error: Uncaught exception 'Defuse\Crypto\Exception\BadFormatException' with message 'Encoding::hexToBin() input is not a hex string.'
in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Encoding.php:65 Stack trace:
#0 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Encoding.php(164): Defuse\Crypto\Encoding::hexToBin('_NEW_COOKIE_KEY...')
#1 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Key.php(38): Defuse\Crypto\Encoding::loadBytesFromChecksummedAsciiSafeString('\xDE\xF0\x00\x00', '_NEW_COOKIE_KEY...')
#2 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/classes/PhpEncryptionEngine.php(112): Defuse\Crypto\Key::loadFromAsciiSafeString('_NEW_COOKIE_KEY...')
#3 /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/classes/PhpEncryptionEngine.php(46): PhpEncryptionEngineCore::loadFromAsciiSafeString('_NEW_COOKIE_KEY...')
#4 /hermes/bosnaweb14a/b1 in /hermes/bosnaweb14a/b1900/ipw.danarostocom/public_html/zumashoes/vendor/defuse/php-encryption/src/Encoding.php on line 65
Warning: Unknown: open(/var/php_sessions/sess_b3c24487f16e9dcc7ebe9b0897bee69f, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
Warning: Unknown: Failed to write session data (files).
Please verify that the current setting of session.save_path is correct (/var/php_sessions) in Unknown on line 0
Might anyone helping me to know how to solve this error??
Thank you for your time
It's throwing an error saying it can't find or write to '/var/php_sessions/'
Do you have full access to the server?
If so, check if that folder exists and if the user or web server has permission to write to it, or change in php.ini
session.save_path = "/var/php_sessions"
To something like :
session.save_path = "/home/user/sessions"
Again, must be an existing folder with read/write permissions for the user or web server (this depends if you run the web server as own user or as account user).
If it's a shared envoirement, you better contact you hosting provider. Some allow you to have a php.ini in your hosting root and you could use it to change the session.save_path, others ignore it.
How to recognize the Error 500
First, we need to go over the different ways you might see this error message on your computer. There are different forms of this message because each host/server is allowed to customize the way it’s displayed. Here are some common ways you might see this error.
“500 Internal Server Error”
“HTTP 500 – Internal Server Error”
“Internal Server Error”
“HTTP 500 Internal Error”
“500 Error”
“HTTP Error 500″
Most times you will see this message accompanied by various forms of this classic ambiguous line
“The server encountered an unexpected condition that prevented it from fulfilling the request by the client”
It’s important to note that this error can be shown on any browser and any operating system (sorry, but switching to the new Mac Pro will not solve this problem) Here is a screenshot of one of the ways this error might be displayed on your browser.
Internal error server
What is the 500 Error?
Put simply, the 500 error is the Web servers way of saying “Something went wrong but I can’t tell you what, sorry.” This is what we call a “server-side” error. That means that there is something wrong with the server who is hosting the website. It is an extremely general error usually caused by configuration issues with the websites programming, PHP or system permissions.
How Can I Troubleshoot?
Don’t fret; although this error message is absurdly vague, you still have ways to find more information. Web servers are almost always configured to hide specific error messages. If your PrestaShop store is suffering from this debilitating error, you can turn on PrestaShop’s Error Reporting from FTP or your hosting’s CPanel to get more details.
There are two ways to turn on Error Reporting in PrestaShop depending on what version you have.
For PrestaShop v1.4 through v1.5.2
Open config/config.inc.php
On or around line 29 you will find this line
#ini_set('display_errors', 'off');
Change that line to read
#ini_set('display_errors', 'on');
For PrestaShop v1.5.3+
Open config/defines.inc.php
On or around line 28 you will find this line
define('_PS_MODE_DEV_', false);
Change that line to read
define('_PS_MODE_DEV_', true);
Once you enable error reporting through your FTP or CPanel, you can navigate back to your PrestaShop’s front or back office and reproduce the error or issue you are having. For example, if you are not able to access your website because of the 500 error, you will need to turn on error reporting and refresh the page(s) that had the error. There will be additional information that you can use to investigate the problem.
Investigating the Error
Once you have the additional information, there are some standard ways to further investigate the error. First, let’s go over some the most common ways this problem is caused. Once we find the cause of this error, it is much easier to solve.
Permissions: Many times you will find that the permission setting on one of your folders is set incorrectly. It could be a simple fix as switching a file/folder permission from 777 to 755 or vice versa. In most cases permission sets of 777 are extremely unsafe and can allow even an amateur hacker to access your files and put malicious code in it. Make sure to check with your hosting provider for specific information about permissions set as some servers have different regulations.
Incorrectly configured .htaccess: Oftentimes you will receive an internal server error when the htaccess file is configured incorrectly. For PrestaShop purposes, the main culprits of the htaccess errors are “URL Rewrite” settings or Friendly URL enabling. The htaccess syntax is very strict so even one wrong character or command will cause the server to return an Internal Error 500. Make a backup of your htaccess and regenerate the htaccess file either through the back office or by toggling the Enable Friendly URL option.
Server timeout: Every server has their own timeout setting, which sets the time that any given script can run. If the function or script crosses that limit, you will receive an error 500. The most common scripts in PrestaShop that can take too long to load are CSV Imports, backups, translation loading, import/exports and thumbnail regeneration. Many times the server limit is 30 seconds, which is not long enough to run these scripts. You should contact your hosting provider and inquire about changing the limit, at least temporarily.
Now, if the problem is not solved by investigating these common causes, you should also take a look at the Apache and PHP Error logs. These are provided by your hosting provider but sometimes you will need to contact them directly in order to have access to these log files.
My company recently added MongoDB to the databases that we use and things have been going mostly smoothly, but every once in a while we get an odd error. It is near impossible to duplicate, and has only happened four times in the last week of testing, but once we go live to production our clients will be using the site much more frequently than we were for testing. We are trying to solve the bug before it gets out of hand.
The error we get is: (line breaks added for readability)
Fatal error: Uncaught exception 'MongoCursorException' with message
'Failed to connect to: 10.0.1.114:27017: send_package: error reading from socket:
Timed out waiting for header data' in
/opt/local/apache2/htdocs/stage2/library/Shanty/Mongo/Connection/Group.php on line 134
We are using ShantyMongo in PHP and it is a remote connection. The error is really intermittent, and refreshing the page is enough to get it to go away. As a temporary solution, we have wrapped all of our mongo methods in a for...try/catch so that if a MongoException is thrown we retry the method up to two more times, the hope being that it will succeed one of the three attempts since the error is so unpredictable.
I'm getting what looks like rather serious database errors in my CodeIgniter application. In the log file it says:
User anders already has more than 'max_user_connections' active connections
And there are several hundred of those lines... I've read a bit by Googling, and some suggested that it was because you didn't close the connection after it was used, but others said that this was nonsense, and that the connection was automatically closed (which is what I read in the docs too).
Also, later in the log file, I have these error messages:
ERROR - 2011-10-12 10:50:19 --> Severity: Warning --> file_get_contents(http://localhost/expertinfo/error/error_general) [function.file-get-contents]: failed to open stream: HTTP request failed! /Applications/MAMP/htdocs/expertinfo/application/errors/error_general.php 4
This seems to have something to do with the fact that I'm using a custom error page by using
echo file_get_contents($config['base_url'] . 'error/error_db');
to redirect to a custom page.
Finally, I'm also getting:
ERROR - 2011-10-12 10:52:19 --> Severity: Warning --> mysql_pconnect() [function.mysql-pconnect]: Can't connect to MySQL server on 'mydb24.surftown.se' (4) /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php 88
In these last two, I don't understand what the local path is doing there (The path to my CodeIgniter app on my computer). I mean this is a part of the system folder and the one on the remote server should be used, right? I have the database set up as the remote database, and I don't have any local paths as far as I know....
So why does this happen, and what can I do about it?
Please help, this seems rather urgent. I'm a bit of a newbie to both php and CodeIgniter too, so a clear and simple answer would be greatly appreciated!
Local path as I see shows you file where your error happened, because your driver /Applications/MAMP/htdocs/expertinfo/system/database/drivers/mysql/mysql_driver.php possible on it's 88 line contain connect() function and it raise an exception
The problem is with your mydb24.surftown.se remote server, you should check your access credentials, etc. to find what exactly happened
Just an FYI, mysql_pconnect is usually a bad practice on shared hosting (you can see why here:http://stackoverflow.com/questions/1830830/advantages-disadvantages-of-pconnect-option-in-codeigniter)
You might just disable pconnect on application/config/database.php and see the error going away as your connections will be realluy lower.
For the quote: "mysql_pconnect is usually a bad practice on shared hosting".
I changed to use mysql_connect. It made no difference.
I'm experiencing a strange situation.
My application logs lot of trace logs to a file. (I don't know exactly how, I use my frameworks logger. Can check this though)
Problems is, when an application is terminated by a fatal error (only fatal) [example - "Fatal error: Call to a member function someFunction() on a non-object"] , I end up with no logs, even logs that should have been recorded much earlier during the execution of my script.
(Yes, I tried to flush logs, this doesn't help either. It looks like the termination of the application by a fatal error, somehow cancels writing to files done at earlier points of the application.
Any ideas what goes on here?
Thank you
A Fatal Error is... well... Fatal : it stops the execution of the script, which will not do anything that should have been done.
In your case, I suppose your logging framework logs into memory -- and that this in-memory log is only written to the file when the processing of the request is done.
Some logging mecanisms do that, to avoid writing to a file several times, at different points during the generation of the response (which means keeping the file locked, to avoid concurrency problems ; or opening-closing-reopening-reclosing-... it)
As you get a Fatal Error, the normal operation that should be done at the end of the response's generation is not called -- and, so, the in-memory log is not written to the file.
Now, the only way to know for sure would be to take a look at the logging mecanisms of your Framework ;-)
Apparently, the fatality of the fatal error that Pascal mentioned, is not 100% fatal.
The below allowed me to have my logs even on fatal errors:
function correctShutdown()
{
logger->flush();
}
register_shutdown_function('correctShutdown');