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
Aleksa Ristic
  • 2,069
  • 1
  • 13
  • 39
  • 1
    It would be awesome if you could provide a [mcve] - including the source code for `UcitajPoslovnePartnere` . – mjwills Jun 26 '18 at 13:11
  • @mjwills added it – Aleksa Ristic Jun 26 '18 at 13:13
  • Please include the full version of Firebird and the Firebird .NET provider used. Also, what is crashing? Firebird or your application? – Mark Rotteveel Jun 26 '18 at 13:50
  • @MarkRotteveel added version (2.1). App is crashing. – Aleksa Ristic Jun 26 '18 at 13:53
  • I asked for the **full** version of Firebird **and the Firebird .NET provider**. – Mark Rotteveel Jun 26 '18 at 13:54
  • 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 `` – Aleksa Ristic Jun 26 '18 at 14:01
  • 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. – Mark Rotteveel Jun 26 '18 at 16:23
  • i would suspect those computers having different DotNet versions (ones of runtimes and/or 3rd party components) – Arioch 'The Jun 27 '18 at 08:24
  • What could i do to inspect this error? – Aleksa Ristic Jun 28 '18 at 15:46
  • I have tried leaving only first event listener (which listen only to one `POST_EVENT`) and it still crashes... – Aleksa Ristic Jun 28 '18 at 15:47
  • @MarkRotteveel at server i am using `Firebird 2.1.7.18553` and `.NET 4` but cannot find `Firebird .NET provider`. Does that changes something? – Aleksa Ristic Jun 28 '18 at 16:03
  • 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? – Ed Mendez Jun 30 '18 at 13:20
  • Server is `32bit`. On my local pc it gets around 45MB on server it gets to 120MB and crash. – Aleksa Ristic Jun 30 '18 at 13:23
  • @MarkRotteveel Please look at edited question. Found something out – Aleksa Ristic Jun 30 '18 at 15:12
  • @AleksaRistic according to this... https://www.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? – Ed Mendez Jul 02 '18 at 17:34
  • @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. – Aleksa Ristic Jul 03 '18 at 12:37
  • @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. – Ed Mendez Jul 03 '18 at 13:22
  • 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 sec – Aleksa Ristic Jul 03 '18 at 21:31
  • @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? – Ed Mendez Jul 06 '18 at 01:59

1 Answers1

-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;");
Legion
  • 744
  • 6
  • 22
  • 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; – Legion Jul 05 '18 at 11:14
  • 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.. – Aleksa Ristic Jul 05 '18 at 13:53
  • 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? – Legion Jul 05 '18 at 14:57
  • 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%? – Legion Jul 05 '18 at 15:01
  • 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. – Aleksa Ristic Jul 05 '18 at 21:11