Solved

Firebird connection timeout

Posted on 2013-12-14
11
2,384 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
[X]
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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 37

Accepted Solution

by:
Geert Gruwez earned 500 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 37

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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...
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 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