-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Fatal error: Uncaught exception 'Predis\Connection\ConnectionException' with message 'Connection refused [tcp://127.0.0.1:6379]' #223
Comments
Connections are lazy which means that Predis doesn't open the connection when initializing the client instance but when sending the first command to Redis. If you need to catch the exception when trying to connect, you should explicitly call $client = new Predis\Client();
try {
$client->connect();
} catch (Predis\Connection\ConnectionException $exception) {
// ...
} I don't know why you need to catch |
Thanks a lot, that's what I needed to know. |
Hi @nrk, as you stated in the doc about connecting to redis (https://github.com/nrk/predis#connecting-to-redis) when you create a redis client with
So how can I catch a connection exception? Thanks! P.S. |
@ivtod I'm not sure if you are missing something, but I'm definitely missing any detail on how exactly it's not working for you: it doesn't throw any exception? it throws a different exception? it fails later in the script? Also, which version of PHP and Predis are you using? I can't help you if you don't disclose a bit more details... As for specifying a timeout for the |
I'm sorry @nrk, I was able to make it work. Thank you very much for your help |
@ivtod |
Hi @cendekia, |
Hi @ivtod, Btw, thank you :) |
I'm trying to catch all Predis exceptions, but even if I use
catch ( \Exception $exception )
I still get a fatal error. How can I catch all exceptions? This is my code:The text was updated successfully, but these errors were encountered: