Ora 12170 tns connect timeout occurred ошибка

TROUBLESHOOTING STEPS (Doc ID 730066.1)

Connection Timeout errors ORA-3135 and ORA-3136
A connection timeout error can be issued when an attempt to connect to the database does not complete its connection and authentication phases within the time period allowed by the following:
SQLNET.INBOUND_CONNECT_TIMEOUT and/or INBOUND_CONNECT_TIMEOUT_ server-side parameters.

Starting with Oracle 10.2, the default for these parameters is 60 seconds where in previous releases it was 0, meaning no timeout.

On a timeout, the client program will receive the ORA-3135 (or possibly TNS-3135) error:

ORA-3135 connection lost contact

and the database will log the ORA-3136 error in its alert.log:

… Sat May 10 02:21:38 2008
WARNING: inbound connection timed out (ORA-3136) …

  • Authentication SQL

When a database session is in the authentication phase, it will issue a sequence of SQL statements. The authentication is not complete until all these are parsed, executed, fetched completely. Some of the SQL statements in this list e.g. on 10.2 are:

select value$ from props$ where name = 'GLOBAL_DB_NAME'

select privilege#,level from sysauth$ connect by grantee#=prior privilege# 
and privilege#>0 start with grantee#=:1 and privilege#>0

select SYS_CONTEXT('USERENV', 'SERVER_HOST'), SYS_CONTEXT('USERENV', 'DB_UNIQUE_NAME'),
SYS_CONTEXT('USERENV', 'INSTANCE_NAME'), SYS_CONTEXT('USERENV', 'SERVICE_NAME'), 
INSTANCE_NUMBER, STARTUP_TIME, SYS_CONTEXT('USERENV', 'DB_DOMAIN') 
from v$instance where INSTANCE_NAME=SYS_CONTEXT('USERENV', 'INSTANCE_NAME')

select privilege# from sysauth$ where (grantee#=:1 or grantee#=1) and privilege#>0

ALTER SESSION SET NLS_LANGUAGE= 'AMERICAN' NLS_TERRITORY= 'AMERICA' NLS_CURRENCY= '$'
NLS_ISO_CURRENCY= 'AMERICA' NLS_NUMERIC_CHARACTERS= '.,' NLS_CALENDAR= 'GREGORIAN'
NLS_DATE_FORMAT= 'DD-MON-RR' NLS_DATE_LANGUAGE= 'AMERICAN' NLS_SORT= 'BINARY' TIME_ZONE= '+02:00'
NLS_COMP= 'BINARY' NLS_DUAL_CURRENCY= '$' NLS_TIME_FORMAT= 'HH.MI.SSXFF AM' NLS_TIMESTAMP_FORMAT=
'DD-MON-RR HH.MI.SSXFF AM' NLS_TIME_TZ_FORMAT= 'HH.MI.SSXFF AM TZR' NLS_TIMESTAMP_TZ_FORMAT=
'DD-MON-RR HH.MI.SSXFF AM TZR'

NOTE: The list of SQL above is not complete and does not represent the ordering of the authentication SQL . Differences may also exist from release to release.

  • Hangs during Authentication

The above SQL statements need to be Parsed, Executed and Fetched as happens for all SQL inside an Oracle Database. It follows that any problem encountered during these phases which appears as a hang or severe slow performance may result in a timeout.

Symptoms of such hangs will be seen by the authenticating session as waits for:
• cursor: pin S wait on X
• latch: row cache objects
• row cache lock
Other types of wait events are possible; this list may not be complete.

The issue here is that the authenticating session is blocked waiting to get a shared resource which is held by another session inside the database. That blocker session is itself occupied in a long-running activity (or its own hang) which prevents it from releasing the shared resource needed by the authenticating session in a timely fashion. This results in the timeout being eventually reported to the authenticating session.

  • Troubleshooting of Authentication hangs

In such situations, we need to find out the blocker process holding the shared resource needed by the authenticating session in order to see what is happening to it.

Typical diagnostics used in such cases are the following:

  1. Three consecutive systemstate dumps at level 266 during the time that one or more authenticating sessions are blocked. It is likely that the blocking session will have caused timeouts to more than one connection attempt. Hence, systemstate dumps can be useful even when the time needed to generate them exceeds the period of a single timeout e.g. 60 sec:
      $ sqlplus -prelim '/ as sysdba' 

       oradebug setmypid 
       oradebug unlimit 
       oradebug dump systemstate 266 
       ...wait 90 seconds 
       oradebug dump systemstate 266 
       ...wait 90 seconds 
       oradebug dump systemstate 266 
       quit
  • ASH reports covering e.g. 10-15 minutes of a time period during which several timeout errors were seen.
  • If possible, Two consecutive queries on V$LATCHHOLDER view for the case where the shared resource being waited for is a latch.
    select * from v$latchholder;
    The systemstate dumps should help in identifying the blocker session.
    Level 266 will show us in what code it is executing which may help in locating any existing bug as the root cause.

Examples of issues which can result in Authentication hangs

  • Unpublished Bug 6879763 shared pool simulator bug fixed by patch
    for unpublished Bug 6966286 see Note 563149.1
  • Unpublished Bug 7039896 workaround parameter
    _enable_shared_pool_durations=false see Note 7039896.8

  • Other approaches to avoid the problem

In some cases, it may be possible to avoid problems with Authentication SQL by pinning such statements in the Shared Pool soon after the instance is started and they are freshly loaded. You can use the following artcile to advise on this:
Document 726780.1 How to Pin a Cursor in the Shared Pool using DBMS_SHARED_POOL.KEEP

Pinning will prevent them from being flushed out due to inactivity and aging and will therefore prevent them for needing to be reloaded in the future i.e. needing to be reparsed and becoming susceptible to Authentication hang issues.

Oracle databases are widely used around the world, and like any other software, they can run into issues. One such issue is the ORA-12170 error, which occurs when a client is unable to establish a connection to the Oracle database server within the specified time period. In this guide, we will provide a comprehensive explanation and step-by-step solution to resolve the ORA-12170 error.

Table of Contents

  • Understanding the ORA-12170 Error
  • Common Causes of ORA-12170 Error
  • Step-by-Step Solution to Fix ORA-12170 Error
  • Step 1: Verify the Basic Network Connectivity
  • Step 2: Check the Listener Configuration
  • Step 3: Validate the SQL*Net Configuration
  • Step 4: Test the Connection with TNSPING
  • Step 5: Adjust the Connection Timeout
  • FAQ

Understanding the ORA-12170 Error

The ORA-12170 error occurs when a client fails to establish a connection to the Oracle database server within the specified time period. The error message looks like this:

ORA-12170: TNS: Connect timeout occurred

This error can be caused by several factors, such as network issues, incorrect listener configuration, or an overly restrictive firewall.

Common Causes of ORA-12170 Error

Some of the common causes of the ORA-12170 error include:

  1. Network connectivity issues between the client and the database server
  2. An incorrect or missing listener configuration
  3. Invalid SQL*Net configuration in the client’s tnsnames.ora file
  4. Insufficient connection timeout value
  5. Firewall restrictions between the client and the database server

Step-by-Step Solution to Fix ORA-12170 Error

Follow these steps to resolve the ORA-12170 error:

Step 1: Verify the Basic Network Connectivity

First, ensure that the client can connect to the database server over the network. You can use the ping command to test the basic network connectivity.

ping <database_server_hostname/IP>

If the ping command fails, check your network configuration and ensure that the client and the database server can communicate with each other.

Step 2: Check the Listener Configuration

Ensure that the Oracle listener is running on the database server and is configured correctly. You can use the lsnrctl status command on the server to check the listener’s status.

lsnrctl status

If the listener is not running, start it using the lsnrctl start command.

lsnrctl start

If the listener is running but is not configured correctly, edit the listener.ora file on the server and update the configuration as needed.

Step 3: Validate the SQL*Net Configuration

On the client side, check the tnsnames.ora file for the correct SQL*Net configuration. Ensure that the hostname, port, and service name in the configuration match the listener configuration on the database server.

Here’s a sample tnsnames.ora configuration:

MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <database_server_hostname/IP>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydb)
    )
  )

Step 4: Test the Connection with TNSPING

Use the tnsping utility on the client to test the connection to the Oracle database server.

tnsping MYDB

If the tnsping test fails, review the previous steps to ensure that the network connectivity, listener configuration, and SQL*Net configuration are correct.

Step 5: Adjust the Connection Timeout

If the tnsping test is successful but you still encounter the ORA-12170 error, consider increasing the connection timeout value. You can do this by adding the TIMEOUT parameter to the CONNECT_DATA section of the tnsnames.ora file.

MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <database_server_hostname/IP>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydb)
      (TIMEOUT = 5000)
    )
  )

In the example above, the connection timeout is set to 5000 milliseconds (5 seconds).

FAQ

What is the default connection timeout value for Oracle databases?

By default, the connection timeout value for Oracle databases is set to 60 seconds.

How can I check the current connection timeout value?

You can check the current connection timeout value in the tnsnames.ora file on the client side. Look for the TIMEOUT parameter in the CONNECT_DATA section.

Can firewall restrictions cause the ORA-12170 error?

Yes, firewall restrictions between the client and the database server can cause the ORA-12170 error. Ensure that the necessary ports (usually 1521 for Oracle databases) are open on the firewall.

Can I change the connection timeout value on the server side?

Yes, you can change the connection timeout value on the server side by editing the listener.ora file and adding the INBOUND_CONNECT_TIMEOUT parameter in the SID_DESC section.

How can I troubleshoot network issues between the client and the database server?

You can use various network troubleshooting tools, such as ping, traceroute, or telnet, to identify network connectivity issues between the client and the database server.

Learn more about Oracle Listener

Oracle SQL*Net Configuration

Oracle TNSPING Utility

I need to connect to remote oracle database using oci_connect(). After waiting for several minutes I get this error.

$db =
  '(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX)(PORT = XXXX))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = citi)
    )
  )';

$conn = oci_connect('username', 'password', $db);
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

$stid = oci_parse($conn, 'SELECT * FROM Tmt');
oci_execute($stid);

I get this following error

PHP Warning:  oci_connect(): ORA-12170: TNS:Connect timeout occurred in /var/www/curiouslabx.com/public_html/wordpress/projects/test.php on line 14
Array
(
    [code] => 12170
    [message] => ORA-12170: TNS:Connect timeout occurred
    [offset] => 0
    [sqltext] => 
)

asked Jan 14, 2017 at 8:36

casper123's user avatar

1

Cause: The server shut down because connection establishment or communication with a client failed to complete within the allotted time interval. This may be a result of network or system delays; or this may indicate that a malicious client is trying to cause a Denial of Service attack on the server.

  • Reconfigure one or all of the parameters SQLNET.INBOUND_CONNECT_TIMEOUT,SQLNET.OUTBOUND_CONNECT_TIMEOUT, SQLNET.SEND_TIMEOUT, SQLNET.RECV_TIMEOUT,TCP.CONNECT_TIMEOUT in sqlnet.ora to larger values.

    • SQLNET.RECV_TIMEOUT — For environments in which clients shut down on occasion or abnormally, setting this parameter is recommended. If a client does not send any data in time specified, then the database server logs ORA-12535: TNS:operation timed out and ORA-12609: TNS: Receive timeout occurred messages to the sqlnet.log file. Without this parameter, the database server may continue to wait for data from clients that may be down or are experiencing difficulties.
    • SQLNET.SEND_TIMEOUT — If the database server cannot complete a send operation in the time specified, then it logs ORA-12535: TNS:operation timed out and ORA-12608: TNS: Send timeout occurred messages to the sqlnet.log file. Without this parameter, the database server may continue to send responses to clients that are unable to receive data due to a downed computer or a busy state.
    • SQLNET.INBOUND_CONNECT_TIMEOUT — If an Oracle Net connection is not established in the time specified, then the connect attempt is terminated. The client receives an ORA-12170: TNS:Connect timeout occurred error. The outbound connect timeout interval is a superset of the TCP connect timeout interval, which specifies a limit on the time taken to establish a TCP connection. Additionally, the outbound connect timeout interval includes the time taken to be connected to an Oracle instance providing the requested service. Without this parameter, a client connection request to the database server may block for the default TCP connect timeout duration (60 seconds) when the database server host system is unreachable. The outbound connect timeout interval is only applicable for TCP, TCP with SSL, and IPC transport connections.
    • SQLNET.INBOUND_CONNECT_TIMEOUT — If the client fails to establish a connection and complete authentication in the time specified, then the database server terminates the connection. In addition, the database server logs the IP address of the client and an ORA-12170: TNS:Connect timeout occurred error message to the sqlnet.log file. The client receives either an ORA-12547: TNS:lost contact or an ORA-12637: Packet receive failed error message.
    • TCP.CONNECT_TIMEOUT — To specify the time, in seconds, for a client to establish a TCP connection (PROTOCOL=tcp in the TNS connect address) to the database server. If a TCP connection to the database host is not established in the time specified, then the connection attempt is terminated. The client receives an ORA-12170: TNS:Connect timeout occurred error. The timeout applies to each IP address to which a host name resolves. For example, if a host name resolves to an IPv6 and an IPv4 address, and if the host is not reachable through the network, then the connection request times out twice the TCP.CONNECT_TIMEOUT setting because there are two IP addresses. In this example, the default timeout setting of 60 would cause a timeout in 120 seconds.
  • If a malicious client is suspected, use the address in sqlnet.log to identify the source and restrict access. Note that logged addresses may not be reliable as they can be forged (e.g. in TCP/IP).

  • Verify that your /etc/hosts file has a DNS entry:
    example XXX.XXX.XXX.XXX myhost

The sqlnet.ora file typically resides in $ORACLE_HOME/network/admin
on UNIX platforms and %ORACLE_HOME%NETWORKADMIN on Windows
operating systems.

In Windows OS, your hosts file is located at
%SystemRoot%System32driversetchosts and on Unix, Unix-like,
POSIX, at /etc/hosts.

Credits: ORA-12170: TNS: Connect timeout occurred tips,Parameters for the sqlnet.ora File

answered Jan 14, 2017 at 9:07

2

At some points, the client sides received intermittent ORA-12170 repeatedly:

ORA-12170: TNS:Connect timeout occurred

Meanwhile, the server side did not receive any errors either in listener.log or alert.log.

ORA-12170 mean that the failed connections did not reach the listener due to network problem. Most likely, they’re blocked by security rules.

Sometimes, there’s a time-out, but what would cause the network time out? What factors that blocked the packets of clients in the pathway to database. Here I made a list for the possibilities of ORA-12170:

  • TNS Names
    • Wrong IP address in TNS entry, which cannot be reachable in your local area network. There maybe a duplicate entry in your tnsnames.ora.
    • Wrong port in TNS entry, which denies all connections by firewall.
  • Hardware or software firewall
  • Poor quality of network
  • Network card interface (NIC) failure
  • Anti-Virus software
    • Detected suspicious packets and blocked them.
    • Was scanning the whole operating system.
  • Intrusion Prevention System (IPS)
  • Intrusion Detection System (IDS)
  • Proxy Server

Solutions

The first step, you need to make sure everything you provided is correct like I said earlier, which includes checking tnsnames.ora.

The most common mistake is that you didn’t open the port 1521 on firewall. That caused ORA-12170. To open port on firewall of the database server, you may refer to these posts:

  • On Linux:
  • How to Open Ports and Survives from Reboots

  • On Windows:
  • How to Open Port on Windows Server

If the firewall is on network appliance, you should ask your network administrator for help.

In our case, we found an IPS applied new rules recently that could caused the problem eventually. To revert the configuration, we rolled back the policy of that IPS. No more ORA-12170.

Other Factors

By the way, if the network appliance really needs more considerable time to complete the validation, you can raise the inbound connect time value of the listener, which is also the solution to ORA-03136 Inbound Connection Timed Out.

Such cases of ORA-12170 happened on the client sides. The management usually misunderstood as a database problem, and ask DBA for resolving it. But the database was healthy during incidents, this reminds us that not all ORA errors are thrown by the database.

oracle tutorial webinars

Error ORA-12170: “TNS: Connect Timeout Occurred” 

There are several possible causes for error ORA-12170. They include: problems with the firewall, when the database is down, when the listener is down, if the sqlnet.ora parm is invalid, among other possible causes.

To fix the error, the user should consider all possible causes and their corresponding solutions on how to get rid of the error. The solution to error ORA-12170 will emerge through process of elimination.

Check to make sure there is no firewall in place between the client and server. If there is, disable the firewall and try again

If the error occurred because there was a delay in the system or network, turn on tracing to determine exactly where clients are timing out.

It may be the case that the Oracle service is running on an IP address while the host is configured to another IP address. To determine the IP address of the Oracle service, issue an lsnrctl status command. Check the address that is reported. To determine the IP address of the host, issue an ipconfig or ifconfig. This is dependent on your operation system; use ipconfig for Windows OS and ifconfig for Linux. To avoid seeing error ORA-12170, use a static IP address rather than a DHCP for assigning an IP address of the host.

In one case, the server may have shut down because the connection establishment or communication with a client did not complete in an allotted time interval. This is probably due to delays within the system or the network, or it may possibly be a client that is trying to maliciously attack by causing a Denial of Service attack on the server.

If the error is occurring because of a slow network or system, you may fix the error by reconfiguring the following parameters in sqlnet.ora to larger values:

SQLNET.INBOUND_CONNECT_TIMEOUT, SQLNET.SEND_TIMEOUT, SQLNET.RECV_TIMEOUT

If the error is occurring due to a malicious attack via a Denial of Service attack, you may use the sqlnet.log to identify the source of attack and restrict the attacker’s access. However, users should be aware that logged addresses might not be entirely reliable. To find your sqlnet.ora file, go to your $ORACLE_HOME/network/admin directory. If the timeout occurs before the IP address can be retrieved by the database server, enable listener tracing to determine the client who made the request.

If you continue to experience problems, contact your business objects administrator or database administrator with the error message information.

Понравилась статья? Поделить с друзьями:
  • Ora 01045 ошибка
  • Ora 01033 ошибка как исправить
  • Ora 01031 insufficient privileges ошибка
  • Ora 01012 not logged on ошибка
  • Ora 00984 ошибка