phporacle-databaseora-12170

PHP error when connect to Oracle 10G R2


I have this code :

ociinternaldebug(1);


// try connecting to the database
 $conn = oci_new_connect('username', 'password', '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.1 )(PORT = 1521)) (CONNECT_DATA = (SID = dpsid)))');

// check for any errors
 if (!$conn)
 {
  $e = oci_error();
  print htmlentities($e['message']);
  exit;
 } 

// else there weren't any errors
 else
 {
  echo 'connected.';
 } 

and I get this error :

    OCI8 DEBUG: OCINlsEnvironmentVariableGet at (ext\oci8\oci8.c:1758) OCI8 DEBUG: OCIEnvNlsCreate at (ext\oci8\oci8.c:2708) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2568) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2580) OCI8 DEBUG: OCISessionPoolCreate at (ext\oci8\oci8.c:2598) OCI8 DEBUG: OCIAttrSet at (ext\oci8\oci8.c:2610) OCI8 DEBUG L1: create_spool: (0x1dde4f0) at (ext\oci8\oci8.c:2626) OCI8 DEBUG L1: using shared pool: (0x1dde4f0) at (ext\oci8\oci8.c:2904) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2915) OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:2925) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:2958) OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:2959) OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (ext\oci8\oci8.c:2961) OCI8 DEBUG: OCISessionGet at (ext\oci8\oci8.c:2972) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1571) 
Warning: oci_new_connect() [function.oci-new-connect]: ORA-12170: TNS:Connect timeout occurred in C:\wamp\www\view\test.php on line 21
OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2150) OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2153) OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1571) ORA-12170: TNS:Connect timeout occurred

I am trying to connect to Remote Oracle database but I am getting this error and I don't know why

what is the problem?


Solution

  • The problem is obvious, sqlnet timeout. The cause is not always that obvious.

    Start with checking the host connectivity: telnet 1.1.1.1 1521 If you get a blank screen and not an error message, your host connectivity is ok. If you get connection refused: your listener is not running, or at least, not on the specified port. if you don't get any response at all, check the firewall[s].

    if this is ok, we can dig deeper.