0

We have had this error recently reported by our clients and we on't know how we can fix this. We are using Delphi XE6 to develop our application and it connect to Firebird (v2.5) database as back-end. We also have used IBObjects for working with Firebird database in Delphi. We have managed to replicate the error on the dev machine by stopping Firebird windows service before running a query but we haven't found a way to detect the connection lost in the code (e.g. by having an event) so as we don't know when this happens so we cannot reconnect to the database in the code either.

By the way, this is full error message if it helps:

ISC ERROR CODE:335544721 ISC ERROR MESSAGE: Unable to complete network request to host "BON-VFS-01". Error writing data to the connection.

Any help really appreciated.

SamZK
  • 13
  • 1
  • 2
  • 2
  • Have a look at http://stackoverflow.com/questions/22338165/firebird-unable-to-complete-network-request-to-host – RBA Mar 14 '16 at 06:06
  • @RBA It sounds more like the connection gets closed in the middle, so most of the points in the answers to that question don't apply. It could be a firewall terminating long running TCP/IP connections. – Mark Rotteveel Mar 14 '16 at 08:25

4 Answers4

1

From IBOBjects FAQ

Is there a way to detect a lost connection and try to reconnect automatically, without user action?

Hook into the OnError event and look for the ERRCODE that denotes a lost connection. Then, you can take whatever action you deem necessary to deal with the problem. If the connection is lost you need to do a disconnect and then connect again.

And from one of the base members of the IBObjects:

However, perhaps the "something" you are missing is that, if the connection is broken by an external cause, the client application has no way to know that it is not still connected. Its first knowledge of that fact will come the next time it tries to access the server. The API will report "Connection lost to database" and return GDSCODE 335544741, which is identified by the constant isc_lost_db_connection.

At the point where this exception occurs, the TIB_Connection still thinks it is connected - the Connected property will be true. If you try to reconnect by calling Connect, you will get an IBO exception. It is necessary to call Disconnect. This does not simply reset a property. The Disconnect method performs all of the necessary cleanup to invalidate the broken transactions and cancel any now invalid postings, datasets and caches. Once Disconnect has completed its work, you can then place a Connect call inside a retry loop and attempt to get going again.

I do not know of a working example, but the simplest way to deal with this is to write a RestoreConnection handler procedure that you can call from your IB_Session.OnError handler whenever argument ERRCODE returns isc_lost_db_connection.

Have your RestoreConnection procedure do whatever you need to do, trying to call Connect and handling the exception that occurs if the request fails, until no exception occurs. Test the Connected property after each iteration. When Connected is finally True, you are in business. You can drop out of the retry code and inform the user that the connection has been restored - perhaps with a sound and/or a message in the status bar, to avoid having to show a dialog box that she has to respond to. (if you like the idea of sound and status bar cues, you could devise "connection lost" warning sound and status bar message code to run at the beginning of your handler procedure as well...)

If these broken connections are a frequent occurrence, you might like to consider making a distinctive custom cursor that you can display while your procedure is running, and enclose the retry code in a non-yielding BeginBusy...EndBusy block with UseCursor enabled and BusyCursor set to use this special cursor image.

And if re-establishing a connection is likely to take a long time, or to be temporarily impossible, you would need to provide the ability for the user to intervene and choose not to keep trying. You can use the session timer for this, enclosing your "busy" block inside another iterative block the prompts the user to "Cancel" or "Keep Trying", at reasonable intervals.

Source

RBA
  • 12,337
  • 16
  • 79
  • 126
0

Check out if their database file is located on mapped network drive. Even if database file path appear to be local to file system, when using embedded Firebird server, function isc_attach_database will return error code 335544721 on attempt to establish connection. Exactly that was happening on my VirtualBox guest Windows XP when I first share entire host D drive and then mapped it again as D drive in virtual guest OS.

Workaround will be to move database file to local partition drive.

Goran
  • 11
  • 2
0

check your query length

max query length is 8191 chars UTF-8

its solved my problem

swagrid
  • 1
  • 1
0

connect your pc to the internet, and the problem will be fixed,but i don't how it works

  • 2
    It would be more helpful if you took a further step by looking up the error code and giving a more detailed answer. Good Job though by making your first post on the platform. – Victor Ejiogu Aug 20 '19 at 08:03