★ wanayoo — archive 1999 https://github.com/phpredis/phpredis/issues/571Nouvelle recherche | Portail wanayoo
Skip to content
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

PHP session. Fatal error with message "Connection closed" #571

Closed
AntonNB opened this issue Mar 2, 2015 · 11 comments
Closed

PHP session. Fatal error with message "Connection closed" #571

AntonNB opened this issue Mar 2, 2015 · 11 comments

Comments

@AntonNB
Copy link

@AntonNB AntonNB commented Mar 2, 2015

Good afternoon, dear developer!

PHP version 5.4.36

PhpRedis version 2.2.7
Redis server 2.8.19

Apache setting:

php_admin_value session.name sid
php_admin_value session.auto_start 1
php_admin_value session.save_handler redis
php_admin_value session.save_path "tcp://x.x.x.x:6379?auth=password&database=0&timeout=60"

Everything works fine. In the evenings, when attendance increases the project, the project begins to run rough.

The logs appear thousands of errors:

PHP Fatal error: Uncaught exception 'RedisException' with message 'Connection closed'
in [no active file]:0\nStack trace:\n#0 {main}\n thrown in [no active file] on line 0, referer: http://...

What should I do?

Maybe comment out all the exceptions zend_throw_exception(*) in the source code? =)

@DartBond
Copy link

@DartBond DartBond commented Apr 2, 2015

Hello, in my production with this bug too.
Configuration:

nginx
spawn-fcgi
redis

session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => redis => redis
session.save_path => tcp://xxx.xxx.xxx.xxx:xxx?db=?&auth=? => tcp://xxx.xxx.xxx.xxx:xxx?db=?&auth=?
session.serialize_handler => php => php
session.use_cookies => On => On
session.use_only_cookies => On => On
session.use_trans_sid => 0 => 0

Error:
PHP Fatal error: Uncaught exception 'RedisException' with message 'Connection closed' in /x/x/php/zend-framework/release-1.11.4/library/Zend/Session.php:480
Stack trace:
#0 /x/x/php/zend-framework/release-1.11.4/library/Zend/Session.php(480): session_start()
#1 /x/x/x/start.php(209): Zend_Session::start()

What should I do?

@EAnushan
Copy link

@EAnushan EAnushan commented May 12, 2015

Most likely your redis server is not externally accessible. You need to edit your redis config and set it's bind address to your public ip or 0.0.0.0 to bind to any address.

@DartBond
Copy link

@DartBond DartBond commented May 12, 2015

This error occurs about 200 times a day from 400 000 requests.
This error is sporadic.

@seasick
Copy link

@seasick seasick commented Oct 18, 2016

I experienced the same behavior. Problem occurs about 20 times in ~150k requests.
To mitigate this, I ended up writing my own session handler, which is using Redis() to store the sessions.

No connection problems with this solution though ...

Edith says: We are using nginx with php5-fpm (5.5) and redis sentinel

@richwandell
Copy link

@richwandell richwandell commented Mar 22, 2017

I am seeing this same problem with php 7 phpredis and amazon elasticache

@gianpaolodn
Copy link

@gianpaolodn gianpaolodn commented Jul 7, 2017

@DartBond I'm having the same sporadic issue. Did you manage to solve this?

@AdvancedStyle
Copy link

@AdvancedStyle AdvancedStyle commented Oct 26, 2017

I'm also having this issue on AWS EC2 + Elasticache. Only a few random times in many connections, but enough to be a problem.

@DartBond
Copy link

@DartBond DartBond commented Oct 26, 2017

@gianpaolodn, sorry for time to reply.
I use redis without native library. By using socket connection like Yii2 library - https://github.com/yiisoft/yii2-redis/blob/master/Connection.php

@gianpaolodn
Copy link

@gianpaolodn gianpaolodn commented Oct 26, 2017

@DartBond in my case the problem is the firewall and ipv6.

@AdvancedStyle
Copy link

@AdvancedStyle AdvancedStyle commented Oct 27, 2017

I found that my problem was creating too many new connections to the redis server, so changing to use "pconnect" instead of "connect" and adding ?persistent=1 in the session handle URL fixed the issue for me..

@yatsukhnenko
Copy link
Member

@yatsukhnenko yatsukhnenko commented Nov 22, 2018

Old issue without activity for a long time. Please open new issue if you have the same issue with the latest stable or develop version of phpredis.

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

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.