You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
OS: Debian Jessie
Redis: 6.0.1
PHP: 7.2.30
phpredis: 5.2.2
Steps to reproduce, backtrace or example script
Works:
$client = new \Redis();
$client->connect('127.0.0.1', 6379);
$client->auth('foo');
$client->set('foo', 'bar');
sleep(10); // Restarting redis server while script is waiting$client->set('foo', 'bar');
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.
Disable the redis.pconnect.echo_check_liveness INI setting. I don't recommend this if you've ever had persistent connections get into a bad state. If this has never happened to you then it's probably OK.
Reacted by chenhao, Jiepeng Cao, sel-fish and voilaf
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 NOAUTH error is sufficient in and of itself to confirm "liveness". The whole point of the liveness check is to make sure there aren't unconsumed replies on the connection when we pull it from the persistent connection pool. If Redis tells us NOAUTH we know for a fact there aren't any replies since we're not even logged in.
I think it will be safe to add NOAUTH as a "success" for the purposes of the liveness check, which should also be pretty simple to implement.
Activity
Venorcis commentedon Jun 17, 2020
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.
xiaoliwang commentedon Jul 21, 2020
I have the same problem. Only if I catch the exception and close the connection, the error 'NOAUTH AUTHENTICATION required' disappear.
michael-grunder commentedon Jul 21, 2020
I can't replicate this with PhpRedis 5.3.0. Both of the examples work fine (and reauthorize the connection)
xiaoliwang commentedon Jul 22, 2020
When i use
tcpkillto kill the tcp connection, I get the 'NOAUTH Authentication required' throwed byconnectfunction.michael-grunder commentedon Jul 22, 2020
Can you provide a bit more context?
From the above sample code, it seems like you'd have a difficult time timing the
tcpkillcall. Or do you mean you're calling it in a loop?xiaoliwang commentedon Jul 23, 2020
Well. I use php 7.3.6 And php-redis 5.3.0
Use nginx and php-fpm
I use the script as below, and I can get the right value.
After that, I use tcpkill to kill the connection. And then stop tcpkill running.
Then I visit the page, I will get the error below.
And then I do the samething to the script below. It's OK. No error appear.
michael-grunder commentedon Jul 23, 2020
Ok I will try that setup tomorrow morning.
michael-grunder commentedon Jul 23, 2020
I can replicate this. I'll post an update when I figure out exactly what's going on.
michael-grunder commentedon Jul 23, 2020
OK, this exception is being thrown in our
ECHO"liveness check".There are two workarounds (as long as you're running >= 5.3.0):
pconnectcall to include the AUTH information:redis.pconnect.echo_check_livenessINI setting. I don't recommend this if you've ever had persistent connections get into a bad state. If this has never happened to you then it's probably OK.JimmyBanks commentedon Jul 23, 2020
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?
michael-grunder commentedon Jul 23, 2020
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
NOAUTHerror is sufficient in and of itself to confirm "liveness". The whole point of the liveness check is to make sure there aren't unconsumed replies on the connection when we pull it from the persistent connection pool. If Redis tells usNOAUTHwe know for a fact there aren't any replies since we're not even logged in.I think it will be safe to add
NOAUTHas a "success" for the purposes of the liveness check, which should also be pretty simple to implement.xiaoliwang commentedon Jul 24, 2020
Thanks @michael-grunder 。I will try。
ERR NOAUTH should be treated as a liveness success
michael-grunder commentedon Oct 31, 2025
If I'm reading the issue correctly this was fixed in d8c7f7a