简体   繁体   English

无法从 Node Express 服务器中的 Firebird 获得响应

[英]Can't get response from Firebird in Node Express Server

I'm trying to establish a connection between my node express server and a Firebird database from an external server.我正在尝试在我的节点快速服务器和来自外部服务器的 Firebird 数据库之间建立连接。 I'm using this node-firebird library我正在使用这个node-firebird

This is my code on my index.js:这是我在 index.js 上的代码:

require("dotenv").config(); //Environment variables
const express = require("express");
const morgan = require("morgan");
const Firebird = require('node-firebird');

//Express Initilization
const app = express();

//MORGAN Configuration
app.use(morgan("dev"));

app.use( express.json() );

app.use( express.static("public") );

const options = {

    "host" : 'externalddns.ddns.net',
    "port" : 3050,
    "database" : 'c:/database/databaseName.fb',
    "user" : 'SYSDBA',
    "password" : 'masterkey',
    "lowercase_keys" : false,
    "role" : null,
    "pageSize" : 4096     

};


Firebird.attach(options, function(err, db) {
 
    if (err) {
        throw err;
    }

    const query = "SELECT * FROM MYTABLE";
    
    db.query(query, function(err, result) {
        if(err){
            console.log(err);
        }
        console.log(result);
        // Close the connection
        db.detach();
    });
 
});
 

app.listen(process.env.PORT, () => {
    console.log("Server running on port " + process.env.PORT);
});

I already open 3050 port on the external site router and firewall.我已经在外部站点路由器和防火墙上打开了 3050 端口。 The connection is working because if I select another path for the database and I do Firebird.create(.....) the database file is being created on the path specified.连接正常,因为如果我 select 为数据库的另一个路径,我执行Firebird.create(.....) ,则数据库文件正在指定的路径上创建。 But I'm not getting any response from the console.log(result) on the db.query , not even an error.但是我没有从db.query上的console.log(result)得到任何响应,甚至没有错误。 The only msg on the console is Server running on port MYPORT .控制台上唯一的消息是Server running on port MYPORT

I can force an error if I change the query to select for a table that doesn't exist in the db.如果我将查询更改为 select 以获取数据库中不存在的表,我可以强制出错。 So the code is working but when it seems to be everything ok I don't get any response.所以代码正在运行,但是当它似乎一切正常时,我没有得到任何回应。

The database file is ok because is working for another service.数据库文件没问题,因为它正在为另一个服务工作。

Is it possible that something on my pc is blocking the response?是否有可能我的电脑上的某些东西阻止了响应? Like firewall or something.像防火墙什么的。 Any help would be appreciated.任何帮助,将不胜感激。

I already know where the problem was.我已经知道问题出在哪里了。 That library was for firebird 2.5+ version and my firebird server version was 2.1.该库适用于 firebird 2.5+ 版本,而我的 firebird 服务器版本是 2.1。 -_- -_-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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