bigcommerce/hello-world-app-php-silex

CredisException

Opened this issue · 5 comments

I'm trying to implement this app on a localhost MAMP environment to get started with my app development. Everything seems to be running correctly on my local environment and the app is getting installed on Bigcommerce as a draft app. However, when it makes its callbacks to my local Auth Callback URL I can't seem to get it to get past this exception. Has anyone else ran into this. If so, how did you resolve it?

It's coming from "hello-world-app-php-silex/vendor/colinmollenhour/credis/Client.php" line 430

CredisException in Client.php line 430:
Connection to Redis failed after 1 failures.Last Error : (61) Connection refused
in Client.php line 430
at Credis_Client->connect() in Client.php line 691
at Credis_Client->__call('set', array('kitty.php:kgxkxz:email@example.com', '{"id":74065,"username":"John Doe","email":"email@example.com"}')) in index.php line 56
at Credis_Client->set('kitty.php:kgxkxz:email@example.com', '{"id":74065,"username":"John Doe","email":"email@example.com"}') in index.php line 56
at {closure}(object(Request))
at call_user_func_array(object(Closure), array(object(Request))) in HttpKernel.php line 145
at HttpKernel->handleRaw(object(Request), '1') in HttpKernel.php line 66
at HttpKernel->handle(object(Request), '1', true) in Application.php line 538
at Application->handle(object(Request)) in Application.php line 515
at Application->run() in index.php line 132

Thanks for your help!

I have same issue.

Can any body help me ?

Same issue... this is how I solved it...
I'm trying to use Heroku as the host service - I hdad to install Redis on Heroku ---
https://devcenter.heroku.com/articles/heroku-redis

Since you are hosting on MAMP - you're going to need redis on your machine. Redis is a non-SQL service that acts like a database but in your memory. The program is trying to cash information to Redis so it can quickly pull it back during the rest of your code (I guess), but if it doesn't exist it throws the error you are getting.

This blue fish article upgrades the composer dependencies from
"colinmollenhour/credis" to "predis/predis": "1.1.*@dev"
(https://www.bluefishgroup.com/insights/ecommerce/create-a-bigcommerce-php-app-on-heroku/)

And also explains how to use Heroku, perhaps you can get some additional information to help you fron their link.

Also, to get it to work on Heroku, change the many lines where it calls the Redis Client by colinmollenhour ....
$redis = new Credis_Client('localhost');
to:
$redis = new Predis\Client(getenv('REDIS_URL'));

This is because Redis needs to point to the URL where Heroku hosts the redis service from their Heroku's URL - the bluefish group link above tells how this is possible and how to make it work with Heroku. previously it was looking to localhost which would have been on your machine... maybe you'll actually want to keep it as local host if you can get redis installed on your MAMP enviornment

getenv('REDIS_URL') is a function that looks up a config file in Heroku...the bluefishgroup article walks you through this step...also you can find documentation on Heroku on how to setup PHP:

https://devcenter.heroku.com/articles/getting-started-with-php

It took me a while to further debug stuff - I had to uninstall the app and re-install it on my demo store which seemed to fix some bugs - it finally works (at least connects)!

If I need to host it in my host now what ? How i can resolve this problem ?!

Hi,

Can someone help. I have uploaded this code to host gator. But it is giving me credisexception failed to connect to redis error.

I also changed also occurrences of localhost to my hostgator domain name where I have have hosted this app. So all places where we had $redis = new Credis_Client('localhost'); I have changed to $redis = new Credis_Client('domaninname.com');

Will we need to ask host gator to install redis?

Many thanks in advance.

Does anyone found solution on this?
I'm using simple hosting with https but still getting an error.
Changing to domain name from $redis = new Credis_Client('localhost'); to $redis = new Credis_Client('domaninname.com'); not helping here.