On Feb 19, 2014, at 11:45 AM, Reza Razavipour <[email protected]> wrote:
> I have a node application and I need to ensure a database connection stays 
> open and operational. I want to do lets say every 30 seconds. What is the 
> customary approach in node?
> 

You can use a setTimeout/setInterval timer to send a periodic dummy query to 
the database to keep the connection alive, but I'd suggest trying to perform 
reconnection gracefully (or report an error if not possible) using whatever 
mechanism your database API/driver provides. For instance, with MySQL you could 
use node-mysql's connection pool mechanism and obtain connections from the pool 
when you have queries to perform.

        --ravi


-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to