8000 Exception when set as session handler · Issue #134 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content
8000

Exception when set as session handler #134

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

Closed
Dynom opened this issue Feb 20, 2012 · 4 comments
Closed

Exception when set as session handler #134

Dynom opened this issue Feb 20, 2012 · 4 comments
Assignees

Comments

@Dynom
Copy link
Dynom commented Feb 20, 2012

I get the following error, when using phpredis as session handler:

Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in /mnt/hgfs/../sesstest.php on line 3
RedisException: Connection closed in /mnt/hgfs/../sesstest.php on line 3
Call Stack:
    0.0006     639184   1. {main}() /mnt/hgfs/../sesstest.php:0
    0.0007     639232   2. session_start() /mnt/hgfs/../sesstest.php:3

Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in [no active file] on line 0
RedisException: Connection closed in /mnt/hgfs/../sesstest.php on line 3
Call Stack:
    0.0006     639184   1. {main}() /mnt/hgfs/../sesstest.php:0
    0.0007     639232   2. session_start() /mnt/hgfs/../sesstest.php:3

However, whenever I use the extension in userland, it works just fine:

$r = new Redis();
$r->connect('localhost');
$r->incr('foo');
var_dump(
    'Redis::get("foo") -> '. $r->get('foo'),
    $r->info()
);

Result:

string(24) "Redis::get("foo") -> 503"
array(44) {
  ["redis_version"]=>
  string(5) "2.4.7"
  ...

I'm currently on commit SHA: a5e53f1 of master.

Session related php.ini settings:

session.save_handler = redis
session.save_path = "tcp://localhost?weight=1"
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
[redis]
extension=/usr/lib/php5/20090626/redis.so
@remyhonig
Copy link

+1

1 similar comment
@kanariezwart
Copy link

+1

@ghost ghost assigned nicolasff Feb 27, 2012
nicolasff pushed a commit that referenced this issue Feb 27, 2012
The port is set to 6379 if not specified.
@nicolasff
Copy link
Member

The port was missing and was set to zero by default, I changed it to 6379 if it is not provided.

Thanks!

@Rudis1261
Copy link

In my case I had some additional configs which were automatically created by Vagrant, I had to look for the file and comment out the duplicate session.save_path vars:
grep -i "session." /etc/php*

After you commented out all the normal session vars and only have the redis ones, restart php:
sudo service php-fpm restart

You should only really have these two in you're php.ini once done:
session.save_handler = redis
session.save_path = "tcp://localhost:6379"

And you can then see if redis is hit by running:
redis-cli monitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
0