Answer the question
In order to leave comments, you need to log in
How to check redis connection with password from php?
Greetings, the question is, how from php, without any libraries, having ip, port, auth pass for redis, check that the connection is possible and the faith data?
Thank you!
Answer the question
In order to leave comments, you need to log in
There's a simple text protocol. You
open a socket, a bit of conversation, and now you know if they want to communicate with you. Then close the socket.
leave a snippet
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_connect($socket, $address, $port);
if($res){
echo 'Redis connected';
socket_write ( $socket , 'auth password'.PHP_EOL );
echo socket_read($socket, 100); //если все ОК, получаем ответ: +OK\r\n
}
socket_close ( $socket );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question