首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >oci_connect() ORA-12170: TNS:连接超时

oci_connect() ORA-12170: TNS:连接超时
EN

Stack Overflow用户
提问于 2017-01-14 08:36:24
回答 1查看 9.5K关注 0票数 1

我需要使用oci_connect()连接到远程oracle数据库。在等待了几分钟之后,我得到了这个错误。

代码语言:javascript
复制
$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);

我得到以下错误

代码语言:javascript
复制
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] => 
)
EN

回答 1

Stack Overflow用户

发布于 2017-01-14 09:07:40

原因:服务器关闭,因为连接建立或与客户端的通信未能在规定的时间间隔内完成。这可能是网络或系统延迟的结果;也可能表示恶意客户端试图在服务器上造成拒绝服务攻击。

  • 超时超时超时超时超时中的一个或全部参数重新配置为更大的值。
代码语言:javascript
复制
- `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.

  • 如果怀疑有恶意客户端,请使用sqlnet.log中的地址标识源并限制访问。注意,记录的地址可能不可靠,因为它们可以伪造(例如,在TCP/IP中)。
  • 验证您的/etc/host文件中有DNS条目:示例XXX.XXX.XXX.XXX myhost

sqlnet.ora文件通常驻留在UNIX平台上的$ORACLE_HOME/network/adminWindows操作系统上的%ORACLE_HOME%\NETWORK\ADMIN中。 在Windows OS中,主机文件位于%SystemRoot%\System32\drivers\etc\hostsUnixUnix-likePOSIX/etc/hosts上。

学分:ORA-12170: TNS:连接超时提示sqlnet.ora文件的参数

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41648168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档