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

Redis URL scheme is not supported, redis://<user>:<password>@<host>:<port> #165

Open
joshnatis opened this issue Nov 4, 2022 · 3 comments

Comments

@joshnatis
Copy link

joshnatis commented Nov 4, 2022

Hello, I'm having trouble getting the client to connect to Redis. Here is a rough reproducer:

use Redis;
my $r = Redis->new(server => $ENV{REDIS_URL});

My Redis URL is in this format: redis://<user>:<password>@<host>:<port>. That's the same as the schema described here: http://www.iana.org/assignments/uri-schemes/prov/redis.

When I try to connect, I get the error "Could not connect to Redis server at <my url>: Invalid argument".

I was able to connect with this URL schema using py-redis:

r = redis.from_url(os.environ.get('REDIS_URL'))

Help please! :D

@joshnatis
Copy link
Author

joshnatis commented Nov 13, 2022

If anybody else runs into this issue in the future, the workaround I went with was breaking the Redis URL up into parts using URI::redis, and then supplying each argument seperately to the constructor.

Like so:

use Redis;
use URI::redis;

my $uri = URI->new($ENV{REDIS_URL});
my $redis = Redis->new(
        server => $uri->host  . ':' . $uri->port,
        password => $uri->password,
);

I also brought up the idea of integrating the redis URL scheme into the base URI module: libwww-perl/URI#119.

It would still be cool for perl-redis to natively understand this Redis URL scheme though.

@joshnatis joshnatis changed the title Could not connect to Redis server at redis://...: Invalid argument Redis URL scheme is not supported, redis://<user>:<password>@<host>:<port> Apr 9, 2023
@davmillar
Copy link

I like this idea and I'd like to try contributing to public Perl code for the first time, so I'm going to try to implement this. @joshnatis would you mind if I pinged you if I run into issues or to try it out when I think it's ready?

@joshnatis
Copy link
Author

@davmillar that's awesome! Sure thing, happy to help -- I'll await your comment

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

2 participants