Re: 20047: DBPROCESS is dead or not enabled

John Kendall <[email protected]> Mon, 19 Sep 2016 16:00:44 +0000
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
> On Sep 19, 2016, at 5:44 AM, LacaK <[email protected]> wrote:
> 
> Hi,
> 
> I am using FreeTDS dblib as client library which connect to SQL Server 2012.
> I am using application which runs in background and sometimes queries SQL Server.
> 
> But when computer where application runs comes into sleep mode, after wakeup next query fails with above mentioned error.
> 
> It is expected, because SQL Server sends keep alive packet and client does not respond, so SQL Server resets connection.
> 
> My question is if there is an elegant way how to handle this situation ?
> How to detect dead dbprocess (there is dbdead(), but I can use this function only after failed query; I can not check status of connection before I send query?) ?
> 
> Or only way is catch exception, check if it is error 20047 and if yes, then connect again and send query again ?

This is what I did.  Although it seemed like a distasteful solution initially, once implemented it worked so well, I got over it.  :)

> Thanks
> 
> -Laco.
> 
> _______________________________________________
> FreeTDS mailing list
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds