Skip to Content.
Sympa Menu

freetds - [freetds] Can't reconnect, why?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Péter András Felvégi" <petschy AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Can't reconnect, why?
  • Date: Tue, 15 May 2007 16:45:56 +0200

Hello,

the link on the support page
(http://www.freetds.org/userguide/help.html) is broken, but hopefully
I can provide the necessary information anyway.

Scenario: I connect to an mssql server successfully. Then, after some
time the connection breaks because of the ISP: read/write errors
(20004/20006). I detect this event, disconnect, then try to reconnect.
The reconnect always fails, no matter how long I try. If I kill the
process, and start my app again, the connect succeeds immediately. I
don't use connection pooling, so I'm a bit confused here. Is there
some internal pooling in the tds lib? Otherwise, the reconnect should
succeed in the same process, right?

I connect like this:

Connect(...)
{
Disconnect();
LOGINREC* loginrec = dblogin();
DBSETLPWD(loginrec, pass_);
DBSETLUSER(loginrec, user_);
DBSETLAPP(loginrec, app_);
DBPROCESS* proc = dbopen(loginrec, const_cast<char*>(server_));
dbloginfree(loginrec);
if (!proc) {
// error
}
// OK ...
}

Disconnect()
{
if (m_connection) {
dbclose(m_connection);
m_connection = 0;
}
}

When the query fails with read/write error, I call Reconnect() which
just calls Connect() in a loop and sleeps a bit between the retries.

I'm using FreeTDS v0.63, on Debian Etch.

my freetds.conf is:

[xxx]
host = xxx.hu
port = 5041
tds version = 8.0
client charset = UTF-8


What's the catch here?

Regards, Peter




Archive powered by MHonArc 2.6.24.

Top of Page