Hello friends I have this error. I'm on an Ubuntu 18.04
A PHP Error was encountered
Severity: Warning
Message: oci_connect(): ORA-12170: TNS:Connect timeout occurred
Filename: models/M_Oracle.php
Line Number: 11
my connection is this
public function __construct()
{
parent::__construct();
echo "<h1>On the constructor</h1><br>";
$this->db_oracle = '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ip_del_servidor)(PORT=1521)))
(CONNECT_DATA=(SID=puvidb)(SERVER=DEDICATED)))';
$this->conexion = oci_connect("my_user", "my_password", $this->db_oracle,"AL32UTF8");
if (!$this->conexion) {
$m = oci_error();
trigger_error(htmlentities($m['message']), E_USER_ERROR);
}
}
I already installed the oci8 drivers, I don't know if they are installed correctly.
I already solved it, I hope it doesn't happen to anyone, the error is not in the code when it appears that my code was correct. But there is a detail and it is that my application is on a Linux server (Ubuntu18.04) and the DB is on another Linux server (Ubuntu18.04) that is, they are separated; Now I was trying to connect through the ip = (ip_publica) what happened is that the server, having to use the public ip, could not connect since these two servers are connected locally, the solution to this is to connect through the ip=(private_ip).
Now I recommend that you try Install SQLPLus on your Ubuntu servers so that you can connect to Oracle DB and use this command. sqlplus User/Password_Del_Usuario@Aqui_va_la_ip_de_la_BD:1521/Aqui_va_EL_SID Example:
sqlplus system/contraseña@localhost:1521/orcl
It is important that you try all the possible IPs if you see that we are not connected. End of solution: