【问题标题】:FBRemoteEvent crashes appFBRemoteEvent 使应用程序崩溃
【发布时间】:2018-12-05 05:16:37
【问题描述】:

我有 fb 远程事件,我用它来监听数据库,并在我的应用程序加载线程内启动它。

当我在我的 Windows 10(本地电脑)上运行它时,它可以正常运行并且完美,但是当我在 Windows Server 2003 上运行它时,它开始填充 RAM 内存比它应该填充的要多得多,当它达到服务器限制时它就会关闭。

这是我的代码:

private void DataBaseEventListner()
{
    FbRemoteEvent revent = new FbRemoteEvent(M.Baza.connectionString);
    FbRemoteEvent revent1 = new FbRemoteEvent(M.Baza.connectionKomercijalno2018);

    revent.RemoteEventCounts += (sender, e) =>
    {
        this.Invoke(new MethodInvoker(delegate
        {
            Poruka p = new Poruka(Magacin.Poruka.UcitajPoslednjuPorukuID(Korisnik.korisnikId));
            p.Show();
        }));
    };

    revent1.RemoteEventCounts += (sender, e) =>
    {
        switch (e.Name)
        {
            case "PP_NEW":
            case "PP_UPD":
                Thread thread1 = new Thread(UcitajPoslovnePartnere);
                thread1.Start();
                break;
        }
    };

    revent.QueueEvents(String.Format("nova_poruka~" + Korisnik.korisnikId.ToString()));
    revent1.QueueEvents(new string[] { "PP_NEW", "PP_UPD" });
}


private void UcitajPoslovnePartnere()
{
    poslovniPartneri = Komercijalno.Partner.Lista();
}

public static List<Int_String> Lista()
{
    List<Int_String> list = new List<Int_String>();
    using (FbConnection con = new FbConnection(M.Baza.connectionKomercijalno2018))
    {
        con.Open();
        using (FbCommand cmd = new FbCommand("SELECT PPID, NAZIV FROM PARTNER ORDER BY NAZIV", con))
        {
            FbDataReader dr = cmd.ExecuteReader();
            list.Add(new Int_String { _int = -1, _string = "<izaberi partnera>" });
            while (dr.Read())
                list.Add(new Int_String { _int = Convert.ToInt32(dr[0]), _string = dr[1].ToString() });
        }
        con.Close();
    }
    return list;
}

我将它包裹在 try-catch 中,我得到的错误是:

从连接中读取数据时出错。
在 FirebirdSql.Data.FirebirdClient.FbRemoteEvent.QueueEvents(String[] events)
在 Magacin.Main.DataBaseEventListner()

在火鸟日志中我得到

TERMINAL_64 (Server)    Sat Jun 30 17:03:52 2018
INET/inet_error: read errno = 10054

我尝试设置Pooling=false,但还是不行

我正在从.TXT 加载我的连接字符串,当我加载它时,我正在构建它:

string[] data = line.Split('|');
//Here I do something with data[0] which is not part of connection string
Baza.connectionString = System.String.Format(@"data source={3};initial catalog = {0};user={1};password={2}", data[1], data[2], data[3], data[4]);

我的.TXT 文件中的字符串是:

C:\Prirucni Magacin\PRIRUCNIMAGACIN.FDB|SYSDBA|masterkey|localhost //This is on local pc

所以最终的字符串看起来像:

data source=localhost;initial catalog = C:\Prirucni Magacin\PRIRUCNIMAGACIN.FDB;user=SYSDBA;password=masterkey

【问题讨论】:

  • 如果你能提供一个minimal reproducible example 那就太好了——包括UcitajPoslovnePartnere 的源代码。
  • @mjwills 添加了它
  • 请包括完整版的 Firebird 和使用的 Firebird .NET 提供程序。另外,什么是崩溃? Firebird 还是您的应用程序?
  • @MarkRotteveel 添加了版本 (2.1)。应用程序崩溃了。
  • 我要求提供 完整版 Firebird 和 Firebird .NET 提供程序

标签: c# server event-handling firebird firebird2.1


【解决方案1】:

根据that bugreport,您的解决方案可能是在您的连接字符串之后设置该参数:

Pooling=false

例子:

new MySqlConnection("SERVER=localhost;DATABASE=myDB;USER=wiii;PASSWORD=wiiii2;POOLING=FALSE;");

【讨论】:

  • 您可以在您的请求中添加您的连接字符串的副本吗?我不确定你能做到这一点,但你可以尝试设置一个连接超时,强制关闭你无法关闭的连接,例如:con.ConnectionTimeout = 30;
  • 尝试将连接超时添加到 conn 字符串仍然无法正常工作。尝试将FbRemoteEvent 添加到我的第一个login 表单的Form_Load() 方法中,在用户按下登录按钮之前我不会打开任何连接,但它仍然让我出错。在那个事件中,我尝试添加池和连接超时,但仍然没有..
  • 这是一个非常奇怪的问题:(但似乎只有在 Server 2003 上你的连接没有正确关闭......在开始连接之前你可以尝试运行该命令 --> FbConnection.ClearAllPools() ; 或者在关闭您的连接测试后,如果它真的关闭并显示一个消息框,如果不是“停止”以下连接(显然只是为了测试目的)。但首先,你的第一个连接会给你一个正确的答案?或者从第一个连接有异常吗?
  • 我这么说是因为您可能只需要更改您的数据库路径,如果您尝试从 %appdata% 读取它,可能在您的服务器中您没有 c:\ 所需的所有权限?跨度>
  • 请再读一遍。我试图在其中启动FbRemoteDesktop 的服务器上的应用程序正常运行,并且与我的数据库(FbDataReader、FbDataAdapter ....)交互时完美运行,但由于某种原因,当我尝试使用 FbRemoteEvent 时它会丢弃此错误。第二件事是新的 FbRemoteEvent 不需要FbConnectionConnectionString 所以我没有将它传递给我的FbRemoteEvent 并且没有办法检查连接是否已经打开,因为我没有创建一个。
猜你喜欢
  • 2017-11-10
  • 2012-08-18
  • 2012-02-12
  • 2014-03-18
  • 2014-11-14
  • 2012-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多