简体   繁体   中英

ArangoDB: Problem with login when connecting from the same server where Arango is running

I have a problem with logging in to ArangoDB from the same server where ArangoDB is running.

We have a running Docker container of ArangoDB in a remote machine which IP is, let's say, 95.123.123.123:8529. When connecting to the DB from our dockerized NodeJS app, which is running in my local machine, in the following way:

import { Database } from 'arangojs';

try {
    const db = new Database({
       url: 'http://95.123.123.123:8529', 
    });
    db.useDatabase('flex');
    db.useBasicAuth('root', 'password');
} catch(err) {
   log('database login failed', err);
}

Login works just fine.

However, when I build our app, dockerize it, and deploy it to the same server where the ArangoDB is running, and using the same method above to login, login fails. Our server app logs then the following error database login failed, Error: EIO: i/o error, write .

How come the login works when connecting from the local machine, but it is not, when logging in from the same remote machine where the Arango is running?

Finally got it working. The issue was using the public IP address instead of the internal one when the server app and arango were in the same server.

Running

docker inspect --format '{{ .NetworkSettings.IPAddress }}' <arangocontainerid>

gives the internal IP address of the container: 172.17.0.4 . And then making the NodeJS server app to point to tcp://172.17.0.4:8529 instead of the public arango IP address, made it work.

However, when accessing to the DB the from the local machine or any machine which is not in the same server with arango, obviously the public IP address http://95.123.123.123:8529 must then to be used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM