• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2770
  • Last Modified:

Firebird connection timeout

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
Thanks
0
LeTay
Asked:
LeTay
  • 5
  • 4
  • 2
1 Solution
 
NickUpsonSenior Network EngineerCommented:
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
0
 
LeTayAuthor Commented:
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 ?
0
 
NickUpsonSenior Network EngineerCommented:
yes, catch the exception and reconnect
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LeTayAuthor Commented:
You mean, "simply" IBDB.Connected := True ?
Will it "understand" that correctly as the property is already (incorrectly) True ?
0
 
NickUpsonSenior Network EngineerCommented:
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
0
 
LeTayAuthor Commented:
Well using interbase of Delphi
In my code, I connect to the database by setting its connected property to True, nothing else
0
 
Geert GruwezOracle dbaCommented:
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
0
 
NickUpsonSenior Network EngineerCommented:
the default port is 3050
0
 
LeTayAuthor Commented:
Do you mean a firewall at client side ?
0
 
LeTayAuthor Commented:
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)
0
 
Geert GruwezOracle dbaCommented:
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
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now