-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Automatic reconnect behavior inconsistent #1757
Comments
I have the same problem, though in a long running script on a replica where (apparently) a connection reset sometimes occurs. After this happened I get the same 'NOAUTH Authentication required' error. |
I have the same problem. Only if I catch the exception and close the connection, the error 'NOAUTH AUTHENTICATION required' disappear. |
I can't replicate this with PhpRedis 5.3.0. Both of the examples work fine (and reauthorize the connection) |
class RedisBase extends Redis
public function __construct()
{
$this->connect('127.0.0.1', 6379);
$this->auth('password');
}
}
new RedisBase(); When i use |
Can you provide a bit more context? From the above sample code, it seems like you'd have a difficult time timing the |
Well. I use php 7.3.6 And php-redis 5.3.0 I use the script as below, and I can get the right value. <?php
$redis = new Redis();
$redis->pconnect('127.0.0.1');
$redis->auth('password');
echo $redis->get('a'); After that, I use tcpkill to kill the connection. And then stop tcpkill running.
And then I do the samething to the script below. It's OK. No error appear. <?php
$redis = new Redis();
try{
$redis->pconnect('127.0.0.1');
$redis->auth('password');
echo $redis->get('a');
} catch(Exception $e) {
$redis->close();
} |
Ok I will try that setup tomorrow morning. |
I can replicate this. I'll post an update when I figure out exactly what's going on. |
OK, this exception is being thrown in our There are two workarounds (as long as you're running >= 5.3.0):
$redis->pconnect('127.0.0.1', 9999, 1, NULL, 0, 0, ['auth' => ['password']]);
|
Thanks @michael-grunder Will this essentially be a necessity to fix the issue for persistent connections, and the best practice moving forward? Or is the underlying issue with the auth() method also fixable in a future version? |
Once persistent connections are fixed we won't need the liveness check at all, so the problem will go away. That said, this specific issue is fixable before that, because in actuality a I think it will be safe to add |
Thanks @michael-grunder 。I will try。 |
Expected behaviour
When automatically reconnect the auth command should always be send.
Actual behaviour
When the server wents away the reconnect sends the auth command, but when reconnecting after calling the close method the auth command isn't sent.
I'm seeing this behaviour on
Steps to reproduce, backtrace or example script
Works:
Isn't working, produces
PHP Fatal error: Uncaught RedisException: NOAUTH Authentication required.
I've checked
develop
branchThe text was updated successfully, but these errors were encountered: