Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 808377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:33:09+00:00 2026-05-15T00:33:09+00:00

I have a situation in which we have two production databases that synchronize with

  • 0

I have a situation in which we have two production databases that synchronize with one other. Server One is considered the primary. Sometimes due to maintenance or a disaster Server Two will become primary.

In some of our code that means we have to manually go in and edit the server name for database connections. I find this annoying, so the last thing I wrote I put the server information for both and set up a loop. If oci_connect failed on the Server One 3 times it would move on to Server Two. If Server Two failed 3 times it would notify the user a connection couldn’t be made.

This has worked fine most times we’ve had the situation of switching the servers. Yesterday, for example, it worked fine. Today it didn’t. It just sat and spun endlessly. No error in the PHP error log. No failure to move on from. No error output to the screen. Nothing for 5 minutes.

So then I had to manually edit the stupid config file.

I asked what could possibly be different and I was told “yesterday the database was down, but not the server. today the server is down.” Okay…? But I don’t see a distinction. I would expect oci_connect to return false if it can’t establish any sort of communication with the server. I’d expect it to timeout and error. Not just pass it on when it receives an error code from the server. What if there’s a network problem, for example?

Is this a bug in oci_connect or is there a possibility that something in our PHP configuration gives oci_connect a crazily long timeout?

If it is a sort of “bug” is there some way I can check to see if the server is up first? Like a ping? (Of course when I did a ping through the command prompt I got a response from Server One and then was told, “it’s back now” although I am skeptical about the timing on that.)

Anyway, if anyone could shed some light on why oci_connect might run endlessly without failing and how to keep it from doing so I’d be grateful.

—
Edit:
My code looks like the examples on PHP.net only in some loops.

 $count = count($servers);
 for($i = 0; $i < $count; $i++){
      if((!isset($connection)) || ($connection == false)){
           // Attempt to connect to the oracle database
           $connection = @oci_connect($servers[$i]["user"], $servers[$i]["pass"], $servers[$i]["conid"]) or ($conn_error = oracle_error());
           // Try again if there was a failure
           if(($connection == false) || (isset($con_error))){
                // Three (two more) tries per alternative
                for($j = $st; $j < $fn; $j++){
                     // Try again to connect
                     $connection = @oci_connect($servers[$i]["user"], $servers[$i]["pass"], $servers[$i]["conid"]) or ($conn_error = oracle_error());
                } // for($j = 2; $j < 4; $j++)
           } // if($connection == false)
      } // if(!isset($connection) || ($connection == false))
 } // for($i = 0; $i < $count; $i++)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:33:09+00:00Added an answer on May 15, 2026 at 12:33 am

    Can you verify that it’s not returning false? Is it perhaps just blocking while waiting for a connection? (what happens if you do var_dump(oci_connect(...))?

    Right from php.net’s documentation:

    If you want to specify a connection
    timeout in case there is network
    problem, you can edit the client side
    (e.g. PHP side) sqlnet.ora file and
    set SQLNET.OUTBOUND_CONNECT_TIMEOUT.
    This sets the upper time limit for
    establishing a connection right
    through to the DB, including the time
    for attempts to connect to other
    services. It is available from
    Oracle 10.2.0.3 onwards.

    In Oracle 11.1, a slightly
    lighter-weight solution
    TCP.CONNECT_TIMEOUT was introduced.
    It also is a sqlnet.ora parameter. It
    bounds just the TCP connection
    establishment time, which is mostly
    where connection problem are seen.

    The client sqlnet.ora file should be
    put in the same directory as the
    tnsnames.ora file.

    Also, you may want to check out FAN on this page… It looks like it may do exactly what you want (but I have no experience with it, so I’m not sure if it’s really right for you).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I have two entities that share a primary key
My situation: I have several components, which sometimes have changes to them, and are
let us have a situation in which the following program prints some 10 lines
I have the situation where i use GIS software which stores the information about
I have the following situation: I built an Access form with a subform (which
Here's the situation. I have a webservice (C# 2.0), which consists of (mainly) a
We have a situation where users are allowed to upload content, and then separately
We have a situation in our product where for a long time some data
I have a situation where I might have multiple instances of a program running
I have a situation where I want to create a signature of a data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.