Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote events don't work [DNET140] #150

Closed
firebird-automations opened this issue Nov 26, 2007 · 25 comments
Closed

Remote events don't work [DNET140] #150

firebird-automations opened this issue Nov 26, 2007 · 25 comments

Comments

@firebird-automations
Copy link

Submitted by: Viner Mihail (mviner)

Attachments:
FbRemoteEventTest.zip

Creating remote events monitoring connection via Firebird .NET Provider 2.0:

FbConnection MonitorConnection = new FbConnection(ConnectionString);
MonitorConnection.Open();
FbRemoteEvent MonitorEvent = new FbRemoteEvent(MonitorConnection, new[] { "DataChanged" });
MonitorEvent.QueueEvents();

QueueEvents fails with:
Exception of type 'FirebirdSql.Data.Common.IscException' was thrown.
at FirebirdSql.Data.Client.Gds.GdsConnection.Connect(String dataSource, Int32 port, Int32 packetSize, Charset charset)
at FirebirdSql.Data.Client.Gds.GdsEventManager..ctor(Int32 handle, String ipAddress, Int32 portNumber)
at FirebirdSql.Data.Client.Gds.GdsDatabase.QueueEvents(RemoteEvent events)
at FirebirdSql.Data.Common.RemoteEvent.QueueEvents()
at FirebirdSql.Data.FirebirdClient.FbRemoteEvent.QueueEvents()

The bug occurres only under Firebird 2.1 Beta 2.
The same code under Firebird 2.1 Beta 1 and earlier work fine.

Commits: 35e905e FirebirdSQL/jaybird@6e30a33 FirebirdSQL/jaybird@c577d79

@firebird-automations
Copy link
Author

Commented by: @dyemanov

What about the post-Beta2 snapshots? Do they have the same issue?

@firebird-automations
Copy link
Author

Commented by: Viner Mihail (mviner)

Current snapshot didn't fix the problem. As well as current FirebirdClient build.

@firebird-automations
Copy link
Author

Commented by: @hvlad

Full text of exception and reproducible example would help

@firebird-automations
Copy link
Author

Commented by: Viner Mihail (mviner)

Here's Microsoft Visual Studio Project for .NET Framework 2.0.
Needs only Firebird 2.1 Beta 2 installed in c:\program files\Firebird_2_1 (possibly with latest snapshot). Current (26.11.07) build of FirebirdSql.Data.FirebirdClient.dll is referenced and included.
Contains compiled executable and console log ConsoleOutput.txt.

@firebird-automations
Copy link
Author

Modified by: Viner Mihail (mviner)

Attachment: FbRemoteEventTest.zip [ 10680 ]

@firebird-automations
Copy link
Author

Commented by: Viner Mihail (mviner)

Thrown FirebirdSql.Data.Common.IscException indicates:
Message = Unable to complete network request to host "0.0.0.0".
ErrorCode = 335544721

@firebird-automations
Copy link
Author

Commented by: @hvlad

1. I have no VS 2008 (why should i have it ???)
2. You hardcoded database name, user name and password
3. I have no c:\program files\Firebird_2_1 at my system

Do you think your test case is useful for anyone ???

Does you reported this issue to the net-provider support list ?

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Hi guys. I'm watching this issue. I'll try to do the test case and send you result. Just wait few days.

@firebird-automations
Copy link
Author

Commented by: @hvlad

This is ancient bug in NetProvider : GdsDatabase.ConnectionRequest reads responce not correctly. It is used recently fixed bug (CORE1460)

Below is draft diff to resolve this issue. Checked agains FB 1.5.2, FB 2.0.3 and current HEAD.

cvs -z9 diff -u -wb -- GdsDatabase.cs (in directory F:\FB2\NETProvider\NETProvider_20\source\FirebirdSql\Data\Client\Gds\)
Index: GdsDatabase.cs

RCS file: /cvsroot/firebird/NETProvider/NETProvider_20/source/FirebirdSql/Data/Client/Gds/GdsDatabase.cs,v
retrieving revision 1.11
diff -u -w -b -r1.11 GdsDatabase.cs
--- GdsDatabase.cs 6 May 2006 21:19:30 -0000 1.11
+++ GdsDatabase.cs 28 Nov 2007 23:18:24 -0000
@@ -279,23 +279,33 @@

				auxHandle = this\.Receive\.ReadInt32\(\);

- // socketaddr_in (non XDR encoded)
+ // garbage
+ this.Receive.ReadBytes(8);

- // sin_port
- portNumber = IscHelper.VaxInteger(this.Receive.ReadBytes(2), 0, 2);
+ int respLen = this.Receive.ReadInt32();
+ respLen += respLen % 4;
+
+ // socketaddr_in (non XDR encoded)

				// sin\_Family
				this\.Receive\.ReadBytes\(2\);

+ respLen -= 2;
+
+ // sin_port
+ byte[] buffer = this.Receive.ReadBytes(2);
+ portNumber = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(buffer, 0));
+ respLen -= 2;

				// sin\_addr

- byte[] buffer = this.Receive.ReadBytes(4);
+ buffer = this.Receive.ReadBytes(4);
+ respLen -= 4;
ipAddress = String.Format(
CultureInfo.InvariantCulture,
"{0}.{1}.{2}.{3}",
- buffer[3], buffer[2], buffer[1], buffer[0]);
+ buffer[0], buffer[1], buffer[2], buffer[3]);

- // sin_zero + garbage
- this.Receive.ReadBytes(12);
+ // garbage
+ this.Receive.ReadBytes(respLen);

				// Read	Status Vector
				this\.connection\.ReadStatusVector\(\);

@firebird-automations
Copy link
Author

Modified by: @dyemanov

Project: Firebird Core [ 10000 ] => .NET Data provider [ 10003 ]

Key: CORE1617 => DNET140

Version: 2.1 Beta 2 [ 10190 ] =>

@firebird-automations
Copy link
Author

Modified by: @carlosga

Fix Version: 2.5.0 [ 10170 ]

Component: http://ADO.NET Provider [ 10041 ]

assignee: Carlos Guzman Alvarez [ carlosga_fb ]

@firebird-automations
Copy link
Author

Commented by: @carlosga

I will fix it tomorrow that i have free evening ^^

@firebird-automations
Copy link
Author

Commented by: @cincuranet

OK. :)

@firebird-automations
Copy link
Author

Modified by: @carlosga

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Commented by: Erick Phillipe Rezende de Almeida (ephillipe)

Hi, I test last version of FirebirdSql.Data.FirebirdClient.dll [2.5.0.0] and the error continue.
-----------
Exceção do tipo 'FirebirdSql.Data.Common.IscException' foi acionada.

em FirebirdSql.Data.Client.Managed.Version10.GdsConnection.Connect()
em FirebirdSql.Data.Client.Managed.Version10.GdsEventManager..ctor(Int32 handle, String ipAddress, Int32 portNumber)
em FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.QueueEvents(RemoteEvent events)
em FirebirdSql.Data.Common.RemoteEvent.QueueEvents()
em FirebirdSql.Data.FirebirdClient.FbRemoteEvent.QueueEvents()
em ConsoleApplication1.Program.Main(String[] args) na C:\DSN\NET\Accounts\ConsoleApplication1\ConsoleApplication1\Program.cs:linha 35
em System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
em System.Threading.ThreadHelper.ThreadStart()

@firebird-automations
Copy link
Author

Commented by: Richard Keast (systemicanomaly)

disregard, furthur testing needed on my part

@firebird-automations
Copy link
Author

Commented by: Steven Rae (stingrae)

Has this issue been resolved yet?
I still get the exception using 2.5.0.0 : 'FirebirdSql.Data.Common.IscException'

@firebird-automations
Copy link
Author

Commented by: @cincuranet

The fixture isn't correct. From list:

From: Christian Nylund
FbConnection conn = new FbConnection(connectionstring);
conn.Open();
FbRemoteEvent revent = new FbRemoteEvent(conn);
revent.AddEvents(new String[] { "NEWEVENTS" });

// Add callback to the Firebird events
revent.RemoteEventCounts += new FbRemoteEventEventHandler(onDBEvent);

// Queue events
revent.QueueEvents();

The code above returns the error described in DNET140 when running provider 2.5.0 on Vista (any DB version) and also when running provider 2.1.0 on Vista (only against 2.1 DB though). Both works fine on my XP developer machine regardless on the version of the DB.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

assignee: Carlos Guzman Alvarez [ carlosga_fb ] => Jiri Cincura [ cincura_net ]

status: Resolved [ 5 ] => Reopened [ 4 ]

resolution: Fixed [ 1 ] =>

@firebird-automations
Copy link
Author

Commented by: @cincuranet

rev.772

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Reopened [ 4 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.0 Alpha 3 [ 10261 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

Fix Version: 2.5.0 [ 10170 ] =>

@firebird-automations
Copy link
Author

Commented by: Richard Clarke (conhulio2000)

Hi,

I would really like this part of it to work.... :-)

Its important that i use this method of getting data, because the traditional way is not efficient enough for me.

As for me - we are using Interbase 7.1. And i tested the events on my Developer machine WinXP Pro, and worked fine. but for some reason when i deploy it to our testing server (Windows Server 2003 Standard SP2), it doesnt work at all. and comes back with the error :

Unable to complete network request to host "n.n.n.n".

which is strange, when i checked database connection with our admin tool to this server it works fine. So - im unsure what the problem here is with this.
I know the http://Firebird.NET was made to be used with Firebird, however Interbase is its father, so with a little tweak in the GetServerVersion i managed to get it working with Interbase 7.1 no problem.

public virtual string GetServerVersion()
{
byte[] items = new byte[]
{
IscCodes.isc_info_firebird_version,
IscCodes.isc_info_end
};

        // For Interbase 7\.1
        return "IB7\.1";
        //return this\.GetDatabaseInfo\(items, IscCodes\.BUFFER\_SIZE\_128\)\[0\]\.ToString\(\);
    \}

Actually - While writing this i added log4net, and started to debug at runtime the problem. And i identified the problem to be here:

connection.Connect();

in this function: public GdsEventManager(int handle, string ipAddress, int portNumber) in Version 10

i think the problem is that our server is running behind a firewall, and its routing is masked, and Interbase doesnt know about it, so when we ask Interbase to give an Event socket, it doesnt know that we cant connect to it.

MORE UPDATE: i just found this article: http://www.firebirdsql.org/doc/whitepapers/events_paper.pdf
read it concerning "How events work: network level"

this will may be explain part of the reason why i am having problems with Events, as this is all i can think is the problem, as on my developer machine its fine, and there is no firewall between my desktop and the Server, in the production environment there is, so this could be the problem.

Take a read, its worth it for future reference.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Events may fail in many cases - NAT, FWs etc. See i.e. the comment in Firebird source code:
* The address returned by the server may be incorrect if it is behind a NAT box
* so we must use the address that was used to connect the main socket, not the
* address reported by the server.

@firebird-automations
Copy link
Author

Commented by: Richard Clarke (conhulio2000)

Hi again,

i tried this, i added log4net debugging, so i could see what was happenning along the way. The IP Address is the same IP Address as the IB Server.

Problem is - the Firewall locks down the ports except 3050.

So - my problem is how do i get Interbase to stop randomising the remote events port. I understand in Firebird, you can set the RemoteAuxPort in the config which presets the port, in Interbase i could not find such a parameter. :-(

So - my question is - can you suggest any good proxy software that can notify back Events ? Otherwise i will have to create one. :-(

Richard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants