Node.js连接Firebird 4.0/5.0失败:客户端与服务器加密级别不兼容
解决Node.js连接Firebird 4.0/5.0时的加密级别不兼容错误
问题描述
使用Node.js的node-firebird库连接Firebird 4.0或5.0时,出现报错:
Error: Incompatible wire encryption levels requested on client and server
已尝试操作:
- 修改
firebird.conf中的WireCrypt参数(在启用/禁用间切换) - 切换到Firebird 5.0测试
- 重启服务器及电脑
- 无法使用Firebird 3.0或更早版本
连接代码如下:
const firebird = require('node-firebird'); const options = { host: "localhost", port: 3050, database: "C:\\Vetor\\INTEGRACAO\\BANCO\\5175_REALIZA_JURANDIR.FDB", user: "SYSDBA", password: "SySkatrog", lowercase_keys: false, role: null, pageSize: 4096, retryConnectionInterval: 1000, // reconnect interval in case of connection drop blobAsText: false, // set to true to get blob as text, only affects blob subtype 1 encoding: "UTF-8" }; firebird.attach(options, function(err, db) { if (err) throw err; });
解决方案
1. 显式指定客户端加密级别
node-firebird默认加密配置可能与Firebird服务器不匹配,需在连接参数中添加wireCrypt选项,与服务器firebird.conf里的WireCrypt值严格对应:
- 若服务器设置
WireCrypt=Enabled,客户端配置:const options = { // 保留原有参数 wireCrypt: "enabled" }; - 若服务器设置
WireCrypt=Disabled,客户端配置:const options = { // 保留原有参数 wireCrypt: "disabled" }; - 若服务器设置
WireCrypt=Required,客户端必须配置:const options = { // 保留原有参数 wireCrypt: "required" };
2. 确认服务器配置生效
修改firebird.conf后,必须重启Firebird服务(而非仅重启电脑),确保新配置加载。同时检查Firebird服务是否指向正确的配置文件(默认路径为Firebird安装目录下的firebird.conf)。
3. 升级node-firebird库版本
旧版本库可能对Firebird 4.0+的加密协议支持不完善,执行命令升级到最新版:
npm update node-firebird
4. 验证Firebird 5.0数据库兼容性
若从Firebird 4.0迁移到5.0,需确保数据库文件完成版本适配:
- 关闭Firebird服务
- 用
gbak工具备份数据库:gbak -b -user SYSDBA -password SySkatrog "C:\\Vetor\\INTEGRACAO\\BANCO\\5175_REALIZA_JURANDIR.FDB" "C:\\backup.fbk" - 用Firebird 5.0的
gbak恢复数据库:gbak -c -user SYSDBA -password SySkatrog "C:\\backup.fbk" "C:\\Vetor\\INTEGRACAO\\BANCO\\5175_REALIZA_JURANDIR_FB5.FDB" - 重启Firebird服务,连接新恢复的数据库测试
内容的提问来源于stack exchange,提问作者Arthur Prezotto Andrade
相关产品推荐
相关产品推荐

