Coder Social home page Coder Social logo

Comments (5)

bigmontz avatar bigmontz commented on June 3, 2024

@lalitkumar-pal-drishya, could you share information about your environment (JS Runtime, Driver version, Neo4j Version, etc) and share some logs? This error is quite general and it can be generated by a bunch of different situations. So, you will need to look through the logs or through the error cause (which are available since Neo4j Driver version 5.0.0 and Node version 16.9.0).

Alternatively, you can swap you protocol from neo4j to bolt(or neo4j+s to bolt+s, if encrypted) for getting a more detailed message.

from neo4j-javascript-driver.

lalitkumar-pal-drishya avatar lalitkumar-pal-drishya commented on June 3, 2024

@bigmontz
Javascript Runtime Version: 18.x
Driver Version: 4.0.3
Neo4j Version and Edition: 5 Enterprize edition.

driver function code

export async function getDriver() {
  let username;
  let password;
  let connection_string;
  if (process.env.LOCAL == 'true') {
    username = process.env.USER_NAME;
    password = process.env.PASSWORD;
    connection_string = process.env.CONNECTION_STRING;
  } else {
    const secrets = await get_secrets();
    username = secrets.username;
    password = secrets.password;
    connection_string = secrets.connection_string;
  }
  return neo4j.driver(connection_string, neo4j.auth.basic(username, password), {
    maxConnectionLifetime: 60 * 60 * 100000, // 1 hour
    maxConnectionPoolSize: 100,
    encrypted: 'ENCRYPTION_OFF',
  });
}

database creation code

export async function create_new_database(plant_id) {
  if (plant_id == '' || plant_id == null) {
    return {
      success: false,
      error: 'Invalid input',
    };
  }
  const database_name = 'db' + plant_id.replace(/[^a-zA-Z0-9\s]/g, '');
  const driver = await getDriver();
  const session = await get_default_database_session(driver);
  const result = await session.run('SHOW DATABASES');
  const database_list = [];
  let status;
  result.records.forEach((record) => {
    database_list.push(record._fields[0]);
  });
  if (database_list.includes(database_name)) {
    logger.info(`Database ${database_name} already exists`);
    status = {
      success: true,
      database_name: database_name,
    };
  } else {
    try {
      await session.run(`CREATE DATABASE ${database_name}`);
      logger.info(`Created database ${database_name}`);
      status = {
        success: true,
        database_name: database_name,
      };
    } catch (err) {
      logger.error(
        `Error creating new database ${database_name} error: ${err}`,
      );
      status = {
        success: false,
        error: err,
      };
    }
  }
  await closeSession(session);
  await closeDriver(driver);
  return status;
}

session code

export async function getSession(driver, plant_id) {
  const database_name = 'db' + plant_id.replace(/[^a-zA-Z0-9\s]/g, '');
  let session;
  try {
    if (driver)
      session = driver.session({
        database: database_name,
      });
    else session = (await getDriver()).session({ database: database_name });
  } catch (err) {
    logger.error(err);
    session = (await getDriver()).session({
      database: database_name,
    });
  }
  return session;
}

logs

I'm getting this error when setting maxConnectionPoolSIze as 1:

Connection acquisition timed out in 60000 ms. Pool status: Active conn count = 1, Idle conn count = 0.

And if I'm setting the maxConnectionPoolSIze greater than 1, we are getting this error:

{
  "errorType": "Neo4jError",
  "errorMessage": "Could not perform discovery. No routing servers available. Known routing table: RoutingTable[database=dbedcd75b117214a23950970bcb52c1df7, expirationTime=0, currentTime=1699275169006, routers=[], readers=[], writers=[]]",
  "trace": [
    "Neo4jError: Could not perform discovery. No routing servers available. Known routing table: RoutingTable[database=my_database, expirationTime=0, currentTime=1699275169006, routers=[], readers=[], writers=[]]",
    "",
    "    at captureStacktrace (/var/task/node_modules/neo4j-driver-core/lib/result.js:239:17)",
    "    at new Result (/var/task/node_modules/neo4j-driver-core/lib/result.js:59:23)",
    "    at Session._run (/var/task/node_modules/neo4j-driver-core/lib/session.js:174:16)",
    "    at Session.run (/var/task/node_modules/neo4j-driver-core/lib/session.js:139:21)",
    "    at /var/task/src/ingest_plant/create_pid.mjs:17:13",
    "    at /var/task/node_modules/p-limit/index.js:23:31",
    "    at run (/var/task/node_modules/p-limit/index.js:23:43)",
    "    at /var/task/node_modules/p-limit/index.js:45:20",
    "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
  ]
}

from neo4j-javascript-driver.

bigmontz avatar bigmontz commented on June 3, 2024

For enabling the logs in driver, you must:

const driver = neo4j.driver(theconnectionstring, theauth, {
   ...theOtherConfigs,
   logging: neo4j.logging.console('debug')
})

I recommend you update the driver to 5.14.0. The version 4.0.x of the driver is not homologated to work with the database 5. If you have to use the version 4.x of the driver because of compatibility issues with existing codebase, you might use the version 4.4.11.

from neo4j-javascript-driver.

bigmontz avatar bigmontz commented on June 3, 2024

Hey @lalitkumar-pal-drishya, did you update the driver? Did it solve the issue?

from neo4j-javascript-driver.

bigmontz avatar bigmontz commented on June 3, 2024

Issues closed due inactivity. Please, feel free to re-open the ticket in case of new evidences.

from neo4j-javascript-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.