FBRemoteEvent crashes app
Asked Answered
D

1

7

I am having fb remote event with which I listen to database and I start it with my app load inside thread.

When I run it on my Windows 10 (local pc) it works normally and perfect BUT when I run it on Windows Server 2003 it start filling RAM Memory a lot more than it should and when it reach server limit it just closes.

Here is my code:

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;
}

I wrapped this in a try-catch and the error I get is:

Error reading data from the connection.
at FirebirdSql.Data.FirebirdClient.FbRemoteEvent.QueueEvents(String[] events)
at Magacin.Main.DataBaseEventListner()

In firebird log I get

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

I tried setting Pooling=false but still not working

I am loading my connection string from .TXT and when i am loading it i am building it like this:

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]);

String inside my .TXT file is:

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

so final string looks like:

data source=localhost;initial catalog = C:\Prirucni Magacin\PRIRUCNIMAGACIN.FDB;user=SYSDBA;password=masterkey
Dowling answered 26/6, 2018 at 13:4 Comment(19)
It would be awesome if you could provide a minimal reproducible example - including the source code for UcitajPoslovnePartnere .Perishing
@Perishing added itDowling
Please include the full version of Firebird and the Firebird .NET provider used. Also, what is crashing? Firebird or your application?Gathard
@MarkRotteveel added version (2.1). App is crashing.Dowling
I asked for the full version of Firebird and the Firebird .NET provider.Gathard
Firebird 2.1.7.18553 (if that means full version) - App is done in .NET 4 and firebird .net provider version I cannot find but if something helps read this <package id="FirebirdSql.Data.FirebirdClient" version="5.12.0" targetFramework="net40" />Dowling
That means the Firebird .net provider version is 5.12.0. In any case, then it is probably not the problem I was thinking of.Gathard
i would suspect those computers having different DotNet versions (ones of runtimes and/or 3rd party components)Albertoalberts
What could i do to inspect this error?Dowling
I have tried leaving only first event listener (which listen only to one POST_EVENT) and it still crashes...Dowling
@MarkRotteveel at server i am using Firebird 2.1.7.18553 and .NET 4 but cannot find Firebird .NET provider. Does that changes something?Dowling
Have you recorded how much peak memory does your application grow to in your windows 10 PC. Also Is your Windows 2003 server 32bit or 64bit?Epperson
Server is 32bit. On my local pc it gets around 45MB on server it gets to 120MB and crash.Dowling
@MarkRotteveel Please look at edited question. Found something outDowling
@AleksaRistic according to this... ibphoenix.com/products/software/ibfirstaid/page_16 the error message has something to do with Network problems. When running the application on the PC vs. windows server is it connecting to the same FB database server? if not can you elaborate more on the connections?Epperson
@EdMendez On local pc it is connecting to local database (that pc is just for testing). On Windows Server pc it connects to database which is located on pc which is located inside local connection with Windows Server (Remote Server). I am using application normally on server with every transaction successful (FbCommand, FbDataReader, FbDataAdapter etc.) but only FbRemoteEvent doesn't work.Dowling
@AleksaRistic on the PC with the DB, check to see if the screensaver is enabled or if the power savings mode is enabled. On local DB vs. the Server's DB... are the events generated the same volume, if the Server's DB is a Prod, maybe that yields a higher volume of events.Epperson
Well it is not on power saving or screen saver. Just to make it clear. I run my app on server (not local) and have test form with 2 buttons. One add row to database and other start event. When i press first button row is added to database, when i press second button to start event to that same database it drops me error. What do you mean with same volume? I have created event on local machine and on database machine same way with copy/paste creation code from local machine to server machine with time difference of 30 secDowling
@AleksaRistic Are you running Firebird Superserver or Classic on your server? how about your PC? in your example you have two connectionstrings, one for each fbremoveevent. Are they point to two DBs on the same server or different servers. Is the client and the DB on the same network?Epperson
A
-1

According to that bugreport Is possible that your solution is setting that parameter after your connectionstring:

Pooling=false

Example:

new MySqlConnection("SERVER=localhost;DATABASE=myDB;USER=wiii;PASSWORD=wiiii2;POOLING=FALSE;");
Angi answered 5/7, 2018 at 8:28 Comment(5)
Can you add to your request a copy of your connection String? I'm not sure you can do that, but you can try to set a connection timeout that force to close the connection that you ccannot close, something like: con.ConnectionTimeout = 30;Angi
Tried adding connection timeout to conn string still not working. Tried adding FbRemoteEvent to my first login form's Form_Load() method where I do not open any connection until user press login button but it still drops me error. Inside that event I tried adding pooling and connection timeout but still nothing..Dowling
It's very weird problem :( but seems that only on Server 2003 you connection doesn't close properly... before start a connection you can try to run that command --> FbConnection.ClearAllPools(); or after closing your connection test if it's really close and show a messagebox if not that "stop" the following connections (just for testing purposes obviously). But first of all, your first connection give you a correct answer? Or since the first connection you got an exception?Angi
I say that because maybe you only need to change your db path, maybe in your server you have not all the privileges you need in c:\ if you try read it from %appdata%?Angi
read again please. APP on server in which i am trying to start FbRemoteDesktop run normally and works perfect with interacting with my database (FbDataReader, FbDataAdapter....) but for some reason it drops this error when i try with FbRemoteEvent. Second thing is that new FbRemoteEvent doesn't require FbConnection but ConnectionString so i am no passing it to my FbRemoteEvent and there is no way to check if connection already opened since i do not have one created.Dowling

© 2022 - 2024 — McMap. All rights reserved.