Skip to content

Support tls:// connection string #249

@tychovbh

Description

@tychovbh

I'm trying to connect my craftcms to a digitalocean redis cluster.

Digitalocean requires a tls:// connection url:
tls://kotc-redis-do-user-698729-0.b.db.ondigitalocean.com

But your plugin doesn't support this only tcp:// and unix://.

I verified that my connection is working if I modify the class Connection.php on line 596:

public function getConnectionString()
    {
        return 'tls://' . ($this->redirectConnectionString ?: "$this->hostname:$this->port");
    }

And my connection worked directly, when I use the tcp:// it returns the following error:

{
    "name": "Redis Socket Exception",
    "message": "Failed to read from socket.\nRedis command was: GET CraftCMS8e0694a5966c89b99615fb42a4a74296",
}

It would be handy to be able to configure de connection scheme mode:

'redis' => [
  'class' => yii\redis\Connection::class,
  'hostname' => getenv('REDIS_HOST'),
  'scheme' => 'tls',
]

My Laravel application already supports the tls:// mode, as you can read here:
https://aregsar.com/blog/2020/connecting-laravel-to-digitalocean-managed-redis-cluster/

What steps will reproduce the problem?

  1. Install craft
  2. Install yiisoft/yii2-redis
  3. Create a Digitalocean managed Redis database
  4. Use the connection details in the craft config/app.php
  5. run your application and open it in the browser

What's expected?

To be able to connect caching with a Digitalocean managed Redis database

What do you get instead?

An error:

{
    "name": "Redis Socket Exception",
    "message": "Failed to read from socket.\nRedis command was: GET CraftCMS8e0694a5966c89b99615fb42a4a74296",
}

Additional info

Q A
Yii vesion 2.0
PHP version 8.1
Operating system mac/ubuntu

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions