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 redis fails if REDIS_HOST starts with tls:// #239

Closed
FeBe95 opened this issue Aug 6, 2024 · 1 comment
Closed

Connection to redis fails if REDIS_HOST starts with tls:// #239

FeBe95 opened this issue Aug 6, 2024 · 1 comment
Assignees

Comments

@FeBe95
Copy link
Contributor

FeBe95 commented Aug 6, 2024

Reverb Version

v1.0.0

Laravel Version

10.48.16

PHP Version

8.2.12

Description

Our Setup

We are using Redis as a database connection in our Laravel app (mainly for caching purposes). Our environment variables looked like this:

REDIS_HOST="tls://master.<endpoint>.cache.amazonaws.com"
REDIS_PASSWORD=<password>
REDIS_PORT=6379

After we installed Laravel Reverb, it failed to connect and showed this message:

Connection to redis://tls://master.<endpoint>.cache.amazonaws.com:6379?password=*** failed:

Connection to tcp://tls:6379 failed during DNS lookup. Last error for IPv4:
DNS query for tls (A) returned an error response (Non-Existent Domain / NXDOMAIN).
Previous error for IPv6: DNS query for tls (AAAA) returned an error response (Non-Existent Domain / NXDOMAIN)

The concatenated URL is obviously incorrect, because it tries to provide two protocols at once: redis:// and tls://. Thus it is that tls is now being parsed as the "host". Clearly tls is not a valid domain, so the DNS lookup fails.

The implementation of laravel/framework handles the additional tls:// protocol at the start of REDIS_HOST just fine, so we expected this to work with laravel/reverb as well.

Custom quick-fix

The quick-fix was to use REDIS_URL directly instead:

REDIS_URL=tls://:<password>@master.<entpoint>.cache.amazonaws.com:6379?database=0

Better custom fix

We have now added

'scheme' => env('APP_ENV') === 'local' ? null : 'tls',

to both database.php and reverb.php configuration files. Then we removed REDIS_URL again, and stripped tls:// from the start of REDIS_HOST.

Long-term fix for laravel/reverb

Support tls:// at the start of REDIS_HOST, like the framework does.

Steps To Reproduce

Set REDIS_HOST to a string that starts with tls://.

@joedixon
Copy link
Collaborator

Reverb uses the same ConfigurationUrlParser as the framework itself, so I think setting scheme as you mention in your "Better custom fix" is probably the right way to go here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants