how to perform an action at a set frequency?

57 views
Skip to first unread message

Reza Razavipour

unread,
Feb 19, 2014, 11:45:15 AM2/19/14
to nod...@googlegroups.com
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?

Thanks

Martin Gonzalez

unread,
Feb 19, 2014, 11:46:39 AM2/19/14
to nod...@googlegroups.com
Hi, Check setInterval() here http://nodejs.org/api/timers.html


--
--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
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 nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Martin

// ravi

unread,
Feb 19, 2014, 11:52:29 AM2/19/14
to nod...@googlegroups.com
On Feb 19, 2014, at 11:45 AM, Reza Razavipour <reza.ra...@gmail.com> 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


Reza Razavipour

unread,
Feb 19, 2014, 12:14:35 PM2/19/14
to nod...@googlegroups.com
this a soap server connection and I do not see a way to do what you are recommending? Am i missing it?

Raymond Feng

unread,
Feb 24, 2014, 5:17:56 PM2/24/14
to nod...@googlegroups.com
Do you access a database via the SOAP/WS API? If so, what SOAP Node.js library do you use?

Thanks,
Raymond

Reza Razavipour

unread,
Feb 24, 2014, 5:31:54 PM2/24/14
to nod...@googlegroups.com
i use soap... npm install soap and then for postgres database I use pg package.



Regards,
Reza


--
--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
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 a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/vWM1wlEXYy8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages