Connection is closed node-firebird

841 views Asked by At

I'm trying to connect my script with my database in Firebird, but I have this error.

This is my code, I'm trying to connect to my local database:

const Firebird = require('node-firebird');

var options = {};
options.host = '127.0.0.1';
options.port = 3050;
options.database = 'C:\\DATABASES\\PRUEBA.FDB';
options.user = 'SYSDBA';
options.password = 'password';
options.lowercase_keys = false; // set to true to lowercase keys
options.role = null;            // default
options.pageSize = 4096;  

Firebird.attach(options, (err, db) => {
  if (err) console.log(err);

  db.query('select * from temp', (err, response) => {
    if (err) console.log(err);

    console.log(response);
  })
})

In my firebird.conf, have this config :

WireCrypt = Enabled
AuthServer = Spr, Legacy_Auth
UserManager = Legacy_UserManager

The error is this, but I don't know what happens:

Error: Connection is closed
1

There are 1 answers

0
Mark Rotteveel On

Based on a little experimenting, it looks like node-firebird will basically just close the connection and report "Error: Connection is closed" when you specify an incorrect password or an unknown user (instead of the normal Firebird error "Your user name and password are not defined. Ask your database administrator to set up a Firebird login.").

And, although the code on GitHub has support for the new Srp authentication mechanism, this isn't actually available in the latest version published to NPM (0.9.9), which only support the old (Legacy_Auth) mechanism. So make sure your user exists for the Legacy_Auth/Legacy_UserManager plugin (which is the case for SYSDBA), and make sure the password matches the one configured for the SYSDBA user created by the Legacy_UserManager (passwords are per user manager, so if a user exists for multiple user managers, it can have different passwords).

If you're not sure, update the password through ISQL using:

alter user sysdba password '<your password>' using plugin Legacy_UserManager;

In short, make sure the user name and password used are valid for the Legacy_Auth/Legacy_UserManager plugin, then your code should work.

As an aside, you need to add a db.detach() at the end of your code.