Firebird 无法完成对主机的网络请求

Firebird Unable to complete network request to host

从我们的 .Net Core Web 应用程序 运行domly 获取此错误消息。连接没有问题。但是在执行抓取一些报告数据的工作过程中,这可能需要 10 秒到 50 秒的时间,我们偶尔会遇到此错误。

完整堆栈跟踪:

System.AggregateException
One or more errors occurred.
System.AggregateException: One or more errors occurred. ---> FirebirdSql.Data.FirebirdClient.FbException: Unable to complete network request to host "
No message for error code 335544721 found. ---> FirebirdSql.Data.Common.IscException: Unable to complete network request to host "
No message for error code 335544721 found. ---> System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at FirebirdSql.Data.Client.Managed.FirebirdNetworkStream.Flush()
   at FirebirdSql.Data.Client.Managed.Version10.GdsTransaction.BeginTransaction(TransactionParameterBuffer tpb)
   --- End of inner exception stack trace ---
   at FirebirdSql.Data.Client.Managed.Version10.GdsTransaction.BeginTransaction(TransactionParameterBuffer tpb)
   at FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.BeginTransaction(TransactionParameterBuffer tpb)
   at FirebirdSql.Data.FirebirdClient.FbTransaction.BeginTransaction()
   at FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet)
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet)
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior)
   --- End of inner exception stack trace ---
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior)
   at Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior)
   at Dapper.SqlMapper.<QueryImpl>d__140`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType)
   at SMP.Legacy.Utility.FirebirdHelper.ExecuteSql[T](String sql) in C:\bamboo-home\xml-data\build-dir\SMAT-SMPAPIB-JOB1\SMP.Legacy\Utility\FirebirdHelper.cs:line 27

正在调用数据库的助手 class 使用此代码:

using System;
using System.Collections.Generic;
using System.Linq;
using Dapper;
using FirebirdSql.Data.FirebirdClient;

namespace SMP.Legacy.Utility
{
    internal static class FirebirdHelper
    {
        public static List<T> ExecuteSql<T>(string sql)
        {
            try
            {
                using (var connection = new FbConnection(DatabaseProvider.ConnectionString))
                {
                    connection.Open();
                    var data = connection.Query<T>(sql).ToList();
                    connection.Close();
                    return data;
                }
            }
            catch (FbException e)
            {
                var error = $"Firebird Exception: {e.ErrorCode} - {e.Message}";
                Console.WriteLine(error);
                throw;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
    }
}

Firebird 版本信息:

火鸟服务器版本:3.0.7.33374

Firebird Sql 数据客户端版本:7.10.1.0

连接字符串:Database=inet://10.100.0.100:3050/F:\Firebird\DATABASE.FDB;User=User;Password=密码;

Firebird 会议:

ServerMode = Super
DefaultDbCachePages = 100K
FileSystemCacheThreshold = 100M
TempBlockSize = 2M
TempCacheLimit = 8000M
AuthServer = Legacy_Auth, Srp, Win_Sspi
AuthClient = Legacy_Auth, Srp, Win_Sspi
UserManager = Legacy_UserManager, Srp
WireCrypt = Enabled 
RemoteServicePort = 3050
LockMemSize = 30M
LockHashSlots = 30011
RemoteAccess = true

我已经让我们的网络人员进行调查,他没有发现任何问题。他 运行 通过我们的 LAN 从普通 PC 到 Firebird 服务器以及从 PC 到 AWS(云)进行了一些测试。这是他的发现。

本地网络 (LAN) – 从 PC 到 FIREBIRD 进行的测试:

• 内部延迟:0.6 毫秒

• TCP 上行速度:768 Mbps/TCP 下行 461 Mbps

• UDP 上行速度:831 Mbps/UDP 下行 521 Mpbs

• UDP 协议丢失(这不适用于 SMP/Firebird)——Firebird 使用 TCP 3050——此测试和数字用于流媒体和 VOICE/VIDEO 解决方案。

o 上传损失:0.2%

o 下载损失:2.1%

这些结果意味着我们的本地网络 (LAN) 运行 非常完美。损失不会导致应用程序和数据的性能问题 t运行sfer.

AWS VPC – 站点到站点 VPN – 从 PC 到 SMATA-PROD 进行的测试:

• Site-to-Site 延迟 (AWS VPC):4 毫秒

• TCP 上行速度:252 Mbps/TCP 下行 325 Mbps

• UDP 上行速度:98 Mbps/UDP 下行 68 Mpbs

• UDP 协议丢失(这不适用于 SMP/Firebird)——Firebird 使用 TCP 3050——此测试和数字用于流媒体和 VOICE/VIDEO 解决方案。

o 上传损失:0.1% - 发生这种情况是因为从我们的服务器到 AWS 对任何 TCP 和 UPD 流量实施了 QoS

o 下载损失:92% - 发生这种情况是因为没有从 AWS 到我们的服务器实施 QoS – 目前这不是问题,因为我们不使用从 AWS 到我们服务器的 UDP。

这些结果意味着我们的 VPC 是 运行 完美的。损失不会导致应用程序和数据的性能问题 t运行sfer.

我检查了与此相关的其他票证,但它们似乎根本没有连接,而我们可以连接并做一些事情。只是 运行domly 它会倒下。当我们的服务器上安装了 Firebird 3 时,对磁盘进行了扫描以删除所有现有的 Firebird 文件,例如 fbclient.dll。

不确定是什么问题。端口侦听设置正确,没有我们知道的防病毒或防火墙问题。有人对此有类似的问题吗?

已更新:

设法通过增加数据库服务器和 Web 客户端服务器上的 MTU 大小来解决此问题。

这是如何通过执行以下测试发现的:

C:\Users\itsupport>ping <server> -l 4096

Pinging <SERVER> [IP ADDRESS] with 4096 bytes of data:
Reply from 169.254.32.138: Packet needs to be fragmented but DF set.
Reply from 169.254.32.138: Packet needs to be fragmented but DF set.
Reply from 169.254.32.138: Packet needs to be fragmented but DF set.
Reply from 169.254.32.138: Packet needs to be fragmented but DF set.

这不好,可能是问题的原因,因为 Firebird 可以 寄大包裹。

这是一篇关于 MTU 大小的不错的文章 https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/mtu-size-matters/ba-p/1025286

并检查 - MTU 似乎是 1394?

C:\Users\itsupport>ping <server> -l 1394 -f

Pinging <SERVER> [IP ADDRESS] with 1394 bytes of data:
Reply from 10.111.0.133: bytes=1394 time=4ms TTL=128
Reply from 10.111.0.133: bytes=1394 time=3ms TTL=128
Reply from 10.111.0.133: bytes=1394 time=3ms TTL=128
Reply from 10.111.0.133: bytes=1394 time=4ms TTL=128

Ping statistics for 10.111.0.133:
     Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
     Minimum = 3ms, Maximum = 4ms, Average = 3ms

C:\Users\itsupport>ping <server> -l 1395 -f

Pinging smp-fb30.netstrata.local [10.111.0.133] with 1395 bytes of data:
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.

Ping statistics for 10.111.0.133:
     Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),