0

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
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Do you have the full stacktrace of that error? – Mark Rotteveel Apr 30 '21 at 07:17
  • I can't reproduce it, your application works fine for me (although I had to add a `db.detach()` for the program to end). If you connect with ISQL, what is the output of `elect sec$user_name, sec$plugin from sec$users`? – Mark Rotteveel Apr 30 '21 at 16:23
  • Actually, I can reproduce an "Error: Connection is closed" if I use an incorrect password. – Mark Rotteveel Apr 30 '21 at 16:24
  • Startign with Firebird 2.5 you may use Trace API to see the exchange with applicaitons from server's point of view. Sometimes it can give you insight what went wrong. There are many commercial and free tools for using Trace API, including CLI `fbtracemgr` (part of Firebird server) and GUI http://fbProfiler.sf.net - check all the classes of messages and look into connection attempt as seen by server. – Arioch 'The May 04 '21 at 12:41

1 Answers1

0

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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197