Connecting to Redislabs

I’m using: SWI-Prolog version 10.0.2

I want the code to: connect to a Redislabs databse

But what I’m getting is:

ERROR: c:/users/chris/documents/prolog/prolog/paths.pl:14:
ERROR: Type error: dict' expected, found 18739’ (an integer)
Warning: c:/users/chris/documents/prolog/prolog/paths.pl:14:
Warning: Goal (directive) failed: user:(((‘.’(18739,c326,_6962478),‘.’(_6962478,us,_6962412)),((‘.’(3,ec2,_6962998),‘.’(_6962998,cloud,_6962908)),‘.’(_6962908,redislabs,_6962818)),‘.’(_6962818,com,_6962280)),redis_server(cloud_db,redis-_6962412-east-1-_6962280:18739,[user(default),password(“==========================”),version(3),tls(true),reconnect(true)]))

My code looks like this:

% Configuration for Redis Cloud
:- redis_server(cloud_db,
redis-18739.c326.us-east-1-3.ec2.cloud.redislabs.com:18739,
[ user(default),
password(“X”),
version(3),
tls(true),
reconnect(true)
]).

% Verify connection
ping_cloud :-
redis(cloud_db, ping, Pong),
writeln(Pong). % Prints status(pong)

I’ve tried many expressions of the address, to no avail, can anyone steer me right? Many thanks.

Do you think you can format the code in this message as code? See here: When posting using mail, please use markdown

This is relevant because now it looks like you have not correctly quoted the URL in your configuration, but it is hard to tell.

Hi,

Thanks for your time.

% Configuration for Redis Cloud
:- redis_server(cloud_db, 
                redis-18739.c326.us-east-1-3.ec2.cloud.redislabs.com:18739,
                [ user(default),
                  password("XXXXXXXXXXXXXXXXX"),
                  version(3),
                  tls(true),
                  reconnect(true)
                ]).

% Verify connection
ping_cloud :-
    redis(cloud_db, ping, Pong),
    writeln(Pong). % Prints status(pong)

I’ve tried none/single/double quoting already, what am I missing?

Surely you get different errors? Try single-quotes around the URL, but leave the colon and port outside of the quotes,

'some.url-in.quotes':12345

I posted because I’ve tried many combos, including your suggestion, read the docs and all Google returns, and still have failed to find the correct expression for Address in redis_connect/3 if the URL is redis-18739.c326.us-east-1-3.ec2.cloud.redislabs.com and the port is 18739.

To clarify - this is a Host:

'redis-18739.c326.us-east-1-3.ec2.cloud.redislabs.com'

Have you tried:

redis_connect('redis-18739.c326.us-east-1-3.ec2.cloud.redislabs.com':18739, Conn, [])

… as indicated in the source code.

My apologies, you were both right, and I thought I’d tried that combo!

The problem was with the host posing as a dict, so this now works.

% Configuration for Redis Cloud
:- redis_server(cloud_db, 
                'redis-18739.c326.us-east-1-3.ec2.cloud.redislabs.com':18739,
                [ user(default),
                  password(xxxxxxxx),
                  version(3),
                  reconnect(true)
                ]).

% Verify connection
ping_cloud :-
    redis(cloud_db, ping, Pong),
    writeln(Pong). % Prints status(pong)