Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Firebird connection timeout

Posted on 2013-12-14
11
Medium Priority
?
2,673 Views
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
Thanks
0
Comment
Question by:LeTay
  • 5
  • 4
  • 2
11 Comments
 
LVL 19

Expert Comment

by:NickUpson
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
0
 

Author Comment

by:LeTay
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 ?
0
 
LVL 19

Expert Comment

by:NickUpson
ID: 39719691
yes, catch the exception and reconnect
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

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

Expert Comment

by:NickUpson
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
0
 

Author Comment

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

Accepted Solution

by:
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
0
 
LVL 19

Expert Comment

by:NickUpson
ID: 39721202
the default port is 3050
0
 

Author Comment

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

Author Comment

by:LeTay
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)
0
 
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

972 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