Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Firebird connection timeout

Posted on 2013-12-14
Medium Priority
Last Modified: 2013-12-24
I have an application that accesses a Firebird database managed by a remote Firebird server.
If there is not activity between the application and the database for a given time (I didn't test for how long it is), then if the application starts some work with the connected firebird server, it gets : "Unable to complete network request to host "....". Error reading data from the connection. An existing connection has been closed by the host" (last phrase I translated from french)
I understand that very well but I want to fix it.
In my code, each time I start some SQL activity, I check if the Connected property of the TIBDatabase is true and if not, I set it to true.
The problem here is that the application see it as true but it is practically not as the host has stopped it !
So my question, what is the best code I can write to "reopen" the connection IF AND ONLY IF IT has been close by the host
Question by:LeTay
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
LVL 19

Expert Comment

ID: 39719679
your problem is that the application doesn't know the connection has gone down until it tries to use it

you need to do a query to test it

Author Comment

ID: 39719680
I understand that but once issuing the query, it will fail so what will I have to code in the exception block to reconnect to it ?
LVL 19

Expert Comment

ID: 39719691
yes, catch the exception and reconnect
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.


Author Comment

ID: 39719695
You mean, "simply" IBDB.Connected := True ?
Will it "understand" that correctly as the property is already (incorrectly) True ?
LVL 19

Expert Comment

ID: 39719715
no, just setting the flag to true will not do it

I don't know which library you are using but somewhere you must have a call that actually connects to the database, you will need to run that again

Author Comment

ID: 39719807
Well using interbase of Delphi
In my code, I connect to the database by setting its connected property to True, nothing else
LVL 38

Accepted Solution

Geert Gruwez earned 2000 total points
ID: 39721113
this is a firewall problem
> when no activity occurs on a connection, it gets severed by the firewall

they will deny it at first due to ignorance
> it usually takes a lot of negotation to solve this problem as the people taking care of the firewall are unaware of this problem
the firewall software should have a log of this

there will be a parameter for this set to 30 minutes on the firewall

a workaround is to have a timer execute a trivial meaningless query every 20 minutes
this sometimes referred to as a heartbeat

if they are unwilling to cooperate (which does happen)
explain them they have following choice:
> you implement the heartbeat query and cause unnecessary excess network traffic
  >> you could setup a test query, which loads massive amounts of data from the database every time
> find the firewall parameter and add an exclusion (or switch the feature off)

they will ask you what port you are connecting to
> this depends on the setup of the firebird database and client

but it's always best to try and work together first ... :)
you could setup 2 programs ... 1 with heartbeat and 1 without
> and then you'll see the one without heartbeat having the problem and the other one won't have the problem
LVL 19

Expert Comment

ID: 39721202
the default port is 3050

Author Comment

ID: 39722692
Do you mean a firewall at client side ?

Author Comment

ID: 39722715
Hello, I come back on that firewall stuff
When I run the application on my own PC, where indeed the Firebird server is located, the timeout also happens (no firewall is running on my PC, I have an ADSL router)
LVL 38

Expert Comment

by:Geert Gruwez
ID: 39723339
why do you indicate you have an ADSL router ?
if you are doing this over internet through your ADSL router then the path you use passes by a provider ...
are you sure this provider doesn't have a firewall ?

you need a map of your IT landscape and all the components in it.
anything on the network path can sever (or interrupt) a connection

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
What we learned in Webroot's webinar on multi-vector protection.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA:…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question