-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Uncaught exception 'RedisException' with message 'Connection closed' on session_start() call #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
anybody? |
Hey, I will attempt to test this but I don't actually use any of the phpredis session stuff, or php sessions at all for that matter. Looking through the code, the exception "connection closed" is only thrown on a socket error when writing to the socket. Are you sure you can connect to the Redis server from within a script executed wihin apache (vs. cli)? |
Yes I verified a script within apache (simple http://host/redis.php) is working and I'm seeing activity when using redis-cli on redis host. $r = new Redis(); works |
Hi Michael, were you able to replicate the issue? thanks, |
@Saritasa Sorry, been a bit mental at work. I haven't set up a test environment for this just yet. I'm going to do my best to set something up this evening. |
Sorry to bug you - Any news? |
@Saritasa Hey, I haven't had the time to test it yet, but I may have noticed something. I see from your original post that it is showing this (in your attached image):
Are you sure there isn't a duplicate |
I had the same issue, but for me the problem was trailing slash, that i copied from http://redis4you.com/articles.php?id=001&name=Redis+as+session+handler+in+PHP Looking at your configuration, it shouldn't be issue for you, but it won't hurt to check if there is not any trailing slash. |
Same problem: |
@KocTbIJIb can you have a look at the link posted above? http://redis4you.com/articles.php?id=001&name=Redis+as+session+handler+in+PHP |
@nicolasff I set up my php.ini exactly like in your suggested post - research around a bit - but I am still getting the same issue when trying to start a session: Warning: Unknown: Failed to write session data (redis). Please verify that the current setting of session.save_path is correct (tcp://localhost:6379) in Unknown on line 0 I can write and retrieve data normally, as per the following code: EDIT: Should note that I am using PHP 5.4.4 with Nginx + PHP-FPM. Hope this helps anyone else having the same problem |
Thanks Thomas, I will try to reproduce it tonight. Nicolas On 9 July 2012 16:49, thomascrown <
|
Thanks for the reply - the issue was hapenning every time, however since then I have edited the post with a solution that I arrived at. By taking tcp:// our of the session path (im using php5.4.4) I was able to get sessions working Only question I have though is, does this affect cases where you would use redis to control sessions over multiple servers? From your config in the readme, you had mentioned using weights with different hosts... etc. and indicated that the use of tcp:// was mandatory to get this working.... |
Hmm, I'm no sure why that wouldn't work with PHP 5.4.4. Nicolas On 9 July 2012 17:42, thomascrown <
|
Thank you very much for looking into it - and also, thank you for all your hard work in creating this amazing program |
Should address #184. Adding a slash at the end would make phpredis consider "/" as the path and ignore the host. Having a host name now takes precedence over having a file name.
@thomascrown I've found an issue and updated phpredis, I would appreciate if you could give it a try. |
@nicolasff Hi again - I fired up the fixed version and it did the trick - thank you for the fast response and solution. |
Great, thanks! |
@nicolasff Hi,I find Uncaught exception 'RedisException' with message 'Connection closed' on session_start() call in php 5.4.6,can u help me? |
@xuguotao could you post some sample code to reproduce the issue? Thanks. |
@nicolasff , thank you for the fast response. this script : $redis = new Redis(); it`s work.... but that script ini_set("session.save_handler","redis"); Exception print: Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in [no active file]:0 Stack trace: #0 {main} thrown in [no active file] on line 0 thanks again~ |
@xuguotao Your call to |
@nicolasff ,i'm sorry,the demo script is my clerical errors,my test script and 'ini_set' both are uses port 6380,the result still wrong... ps: |
I am getting the same error using:
I've enabled debug level logging, though there is nothing in the error log. PHP Exception
|
When I set all my settings in ini_set('session.save_handler','redis');
ini_set('session.save_path','tcp://10.0.0.1:6333?weight=1');
|
Hey there, This works just fine for me. It could be a longshot but you are using port 6333 in your example, but the error is reporting port 6379. Could it possibly be a typo? Cheers, |
@michael-grunder — However, I also had a second typo. An extra Works now. 👍 |
Would like to see let it here. May be it will help some one as it have done for me. Exception when connected to socket could appear if apache/php user hasn't got rights to write to redis sock, so please check it :) |
I've the same problem. None of the solutions described in this issue worked for me. I'll post more information here when I have some time. |
Caching to Redis works just fine, the only problem is sessions. ini_set("session.save_handler","redis");
ini_set("session.save_path","tcp://localhost:6379"); //or "localhost:6379" or add "/"
session_start();
$_SESSION['redis'] = "aaaaaa";
echo session_id();
echo $_SESSION['redis']; Sure enough, I get this output:
My PHP version is 5.4.17 and I'm using latest master branch of PhpRedis. I've tried it both with and without igbinary and got the same results. @michael-grunder What other information should I provide? Also can you reopen this issue? |
Same problem with php-redis 2.2.3 and PHP 5.3.27-1~dotdeb.0. I tried different urls in session.save_path but i still get error. |
@devdemi: I've solved it with custom session handler. This one is for Nette framework but you can easily modify it for plain PHP. |
I have the same problem with php-redis master branch and php 5.4.9, |
Hi, Please double check your config files. check your /etc/php.ini add the following session.save_handler = redis session.save_path = "tcp://127.0.0.1:6379" also scroll down your php.ini and make sure there are no more session.save_path's as they will override your settings, just comment them out. Also if you're on Centos or the like check your /etc/httpd/conf.d/php.conf as well. Check the following are commented out #php_value session.save_handler "files" #php_value session.save_path "/var/lib/php/session" restart apache and you should be good to go. ta, |
Hi, I'm using phpredis 2.2.3, and I get the same error, but just from time to time. I'm running on amazon EC2 and my Redis server is an Elasticache node. |
Hey, Generally this has to do with pconnect and/or timeouts on the PHP or Redis side of things. It can happen when a connection is idle for too long and either side resets the connection. phpredis does have reconnect logic, but sometimes that doesn't work. What are your timeouts, etc? Cheers, |
Sorry, more info below: I just began to see a pattern, with these errors happening around the time new webservers launch or are terminated, so this might be an external network issue after all... I'll keep you posted. Thanks |
Thanks for the update. Please post anything you find in this issue thread and maybe we can track it down (if it is in phpredis). Cheers! |
Same error. PHP 5.4.21-1~dotdeb.0 (cli) (built: Nov 2 2013 21:32:49) ii redis-server 2:2.6.16-1~dotdeb.0 amd64 Persistent key-value database with network interface |
Nevermind, my bad. This sometimes happens if session.save_path is declared via php_admin_value in apache configs, therefor whatever you do in your code, you get "Connection closed". My advice would be to add current session_save.path to the exception text. |
I had the same problem, but i found out that PHP script itself had session configuration |
I use Vagrant boxes for my dev, be sure to check any custom .ini files for session vars: After you commented out all the normal session vars and only have the redis ones, restart php: You should only really have these two in you're php.ini once done: And you can then see if redis is hit by running: |
Same error rpm -qa|grep redis php -i|grep save_handler -A1 PHP Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in test.php content in test.php: session_start(); |
Same for me as the message above but in Debian 7, with pecl redis extension (2.2.7). Tried with tcp://, without tcp, with unix socket... always getting the same error message: PHP Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in ... session.save_handler = redis Tried setting this in php.ini and .htaccess and I always get the same "Connection closed" error message. Tried also compiling the develop branch with no luck. EDIT: Had some additional session.save_path set with ini_set that was breaking the config. Removed it and all works fine now. Thanks! |
Please forgive me my lousy English. A person using Contents of For example, Please execute the next program on WebServer.(not php-cli) <?php
var_dump(ini_get("session.save_handler"));
var_dump(ini_get("session.save_path")); |
Hi this worked for me both on unix and TCP sockets, session.save_path set in php.ini or fpm php_admin_value as well. Important point : For unix socket, the .sock file need to be writable by php-fpm user Bests |
The fix for me was to just restart Redis.
|
In my case, These just delete the key, see: https://redis.io/commands/expire. I had tested that the maximum expire time in Redis was 2147483647 (0x7fffffff). So, I solved this issue by set |
I found this problem when connecting a PHP-FPM + PHP 7 server to AWS elasticache using phpredis extension. The server has been running fine without any restart for a few days and randomly started throwing this error. |
I'm having a similar problem mentioned by @richwandell any updates on a fix for this? |
The original issue is resolved. @richwandell, @aranw, open new issue and provide more information |
I had similar issue on PHP-FPM + PHP 7 restart redis server did the job for me... |
I got the same error message when SELinux was set to enforcing in CentOS 7. I had set permissive mode in |
session.save_handler = redis
session.save_path = "tcp://10.100.100.50:6379" - this points to server1
http://screencast.com/t/FMnHMnxc
I get the following error:
Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in /home/www/sites/production/html/backend/connect.php:31 Stack trace: #0 /home/www/sites/production/html/backend/connect.php(31): session_start() #1 /home/www/sites/production/html/backend/controller.php(5): require_once('/home/www/sites...') #2 {main} thrown in /home/www/sites/production/html/backend/connect.php on line 31
Fatal error: Exception thrown without a stack frame in Unknown on line 0
I can use redis-cli to set the variable on PHP server (server2)
and I see it using redis-cli on REDIS server (server1) using "monitor" command
so firewall is not the issue
any ideas?
I saw this bug
#134
and that script
$r = new Redis();
$r->connect('10.100.100.50:6379');
$r->incr('foo');
var_dump(
'Redis::get("foo") -> '. $r->get('foo'),
$r->info()
);
works just fine
not sure if it's got back in the src again somehow.
The text was updated successfully, but these errors were encountered: