1
votes

I am using activerecord-oracle_enhanced-enhanced (1.6.6) gem to connect with the oracle database from the rails app (rails 4.2.5)
I need to set the Database connection timeout.
Below are the setting used in database.yml file,

development:  
    adapter: oracle_enhanced  
    host: 10.10.10.58  
    port: 1521  
    database: TUTSDB  
    username: tutsadmin  
    password: Tuts1234  
    encoding: utf8  
    timeout: 15000  

I have specified the timeout to be 15 sec.
Even after doing this we are getting the below error:
(ActiveRecord::ConnectionTimeoutError) "could not obtain a database connection within 5 seconds (waited 5.000144774 seconds).
It is waiting for the connection only for 5 seconds (which is the default timeout value). Ideally it should wait for 15 sec.

1
Just how slow is your database? That sounds like a broken configuration if it takes that long. Is it resolving reverse DNS names on connect?tadman
No. There are many connections due to which it is unable to make new connection. It waits for 5 seconds and throws the above error.Kalyani Kirad
Make sure you're testing your app in development mode. You've set the timeout in the development mode here. Or set it in all modes and then test.CppNoob

1 Answers

0
votes

Looking at the Timeouts guides it seems that you have to set the timeout otherwise:

development:
  database: "(DESCRIPTION=
    (ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
    (CONNECT_TIMEOUT=5)(TCP_CONNECT_TIMEOUT=5)
    (CONNECT_DATA=(SERVICE_NAME=xe))
  )"