Skip to content
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

Connection to remote Redis Server fails #365

Closed
Mudders opened this issue Dec 12, 2019 · 1 comment
Closed

Connection to remote Redis Server fails #365

Mudders opened this issue Dec 12, 2019 · 1 comment

Comments

@Mudders
Copy link

Mudders commented Dec 12, 2019

What steps will reproduce the problem?

Install yii-soft/redis and yiisoft-yii2-queue
Set yii-soft/redis config to point to a remote server

'queue' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis', // Redis connection component or its config
            'channel' => 'queue', // Queue channel key
        ],
'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => '78.xx.xx.xx',
            'port' => 6379,
            'database' => 0,
            'password' => 'PASSWORD',
        ],

Run the command ./yii queue/info

What's expected?

Expect the info of the queue to be shown.

What do you get instead?

Error message saying connection refused and not attempting to use the settings in the 'redis' section.

Exception 'yii\db\Exception' with message 'Failed to open redis DB connection (tcp://127.0.0.1:6379, database=0): 111 - Connection refused'

in /var/www/html/vendor/yiisoft/yii2-redis/src/Connection.php:609

Error Info:
Connection refused
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2-redis/src/Connection.php(710): yii\redis\Connection->open()
#1 /var/www/html/vendor/yiisoft/yii2-redis/src/Connection.php(675): yii\redis\Connection->executeCommand('LLEN', Array)
#2 /var/www/html/vendor/yiisoft/yii2-queue/src/drivers/redis/InfoAction.php(32): yii\redis\Connection->__call('llen', Array)
#3 /var/www/html/vendor/yiisoft/yii2-queue/src/drivers/redis/InfoAction.php(32): yii\redis\Connection->llen('queue.waiting')
#4 [internal function]: yii\queue\redis\InfoAction->run()
#5 /var/www/html/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)
#6 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\Action->runWithParams(Array)
#7 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('info', Array)
#8 /var/www/html/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('info', Array)
#9 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('queue/info', Array)
#10 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('queue/info', Array)
#11 /var/www/html/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#12 /var/www/html/yii(20): yii\base\Application->run()
#13 {main}

Additional info

I have tested a simple SET GET in my Yii2 code and then logged into the Redis server and can see the Key/Value set in the Redis server. So the connection directly using yiisoft/redis is working.

Perhaps I missed a configuration setting somewhere?

Q A
Yii version 2.0.30
PHP version 5.6.40
Operating system Ubuntu
@Mudders
Copy link
Author

Mudders commented Dec 12, 2019

Found the issue - I hadn't added the config to the config/console.php file.
Once added there all worked.
Thanks for the great extension. Very useful.

@Mudders Mudders closed this as completed Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant