ping database to keep connection alive

I'm running rails behind a firewall which times out idle tcp connections. What would be the best way to have rails ping the database every so many minutes? Or alternatively, is it possible to ping it myself before the session (which uses a database) is created?

Chris

Well it appears that I could use ActiveRecord::Base.connection.verify!, now the question is how to verify before the session is accessed.

The simplest way is to set up a cron job somewhere to curl http://myapp.

You could also experiment with something like Thread.new do loop { ActiveRecord:: Base.verify_active_connections!; sleep 300 } end

jeremy

I think you are right, the simplest is probably the best.