horizon
horizon copied to clipboard
Server: connect with rethinkdb as hostname fails
Server version: 2.0.0
So I'm using Docker and linking rethinkdb into my horizon container.
hz serve --dev --connect rethinkdb:28015 --secure=no --bind all --allow-anonymous=yes /usr/app throws:
error: Connection to RethinkDB terminated: ReqlDriverError: Could not connect to 28015:28015.
connect EINVAL 0.0.109.111:28015 - Local (0.0.0.0:0)
hz serve --dev --connect rdb:28015 --secure=no --bind all --allow-anonymous=yes /usr/app works fine though
Dumping the rdb_uri from url.parse(connect) I get:
Url {
protocol: 'rethinkdb:',
slashes: null,
auth: null,
host: '28015',
port: null,
hostname: '28015',
hash: null,
search: null,
query: null,
pathname: null,
path: null,
href: 'rethinkdb:28015' }
Hmm is 0.0.109.111 a valid IP address? (@encryption ?)
The actual IP address that rethinkdb was resolving to was:
PING rethinkdb (172.20.0.5): 56 data bytes
64 bytes from 172.20.0.5: icmp_seq=0 ttl=64 time=0.145 ms
I believe the problem is the parser picking up the rethinkdb: from rethinkdb:28015 as a protocol.
The IP comes from 28015 as a hostname as can see via ping:
ping 28015
PING 28015 (0.0.109.111): 56 data bytes
ping: sendto: No route to host
Seems like that's what's happening. You can work around it by using a full URI with protocol, like rethinkdb://rethinkdb:28015.
I think this can be fixed in horizon by requiring rdb_uri.slashes in serve.js to be true to accept a rethinkdb: protocol, which is only the case if the full rethinkdb:// prefix is used.
Deleted my prev. comment. After I posted it, I spotted the 'rehinkdb' typo.
Changing the docker-compose.yml to the workaround until fixin would have saved a lot of time too :-/