Solved

how to set a connection timeout for ORACLE PLSQL UTL_TCP.open_connection

Posted on 2010-11-30
6
4,893 Views
Last Modified: 2012-06-27
anybody know how to set a connection timeout?  if the host is down the open_connection takes 3 or 4 minutes of hanging and then an exception.  A host being down can happen and it would be good to set say a 10 second timeout.

TNS:operation timed out
ORA-29260: network error: TNS:operation timed out

DECLARE
  c  utl_tcp.connection;  -- TCP/IP connection to the Web server
  ret_val pls_integer;
BEGIN
  c := utl_tcp.open_connection(remote_host => '8.8.8.8',
                               remote_port =>  9330,
                               charset     => 'US7ASCII');  -- open connection
  ret_val := utl_tcp.write_line(c, 'GET /axis/services/NSRAPIService HTTP/1.0');    -- send HTTP request
  ret_val := utl_tcp.write_line(c);
  BEGIN
    LOOP
      dbms_output.put_line(utl_tcp.get_line(c, TRUE));  -- read result
    END LOOP;
  EXCEPTION
    WHEN utl_tcp.end_of_input THEN
      NULL; -- end of input
  END;
  utl_tcp.close_connection(c);
END;
0
Comment
Question by:cavtel
6 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34242223
There appears to be a timeout parameter for open_connection:

http://psoug.org/reference/utl_tcp.html
0
 
LVL 34

Expert Comment

by:johnsone
ID: 34242382
From the doc:

http://download.oracle.com/docs/cd/E11882_01/appdev.112/e16760/u_tcp.htm#i997069

You should be able to supply the TX_TIMEOUT parameter to the OPEN_CONNECTION function.
0
 

Author Comment

by:cavtel
ID: 34249051
unfortunately that tx_timeout is transfer_timeout used for read and write, after the connection is made.

the utl_http function works the same way, you can set a request timeout, but not on the initial connection.

the connection will hang for 3 minutes, i was trying to figure out an alter session parameter to shorten that 3 minutes as a work around.  but couldnt figure that out either.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34250542
UTL_TCP might be governed by the sqlnet parameters.  You might tweak these to see if they make a difference:

http://download.oracle.com/docs/cd/E11882_01/network.112/e10835/tnsnames.htm#NETRF1434
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 150 total points
ID: 34250558
0
 
LVL 5

Accepted Solution

by:
anand_20703 earned 350 total points
ID: 34291363
in database server's listener.ora, there are two parameters.
inbound_connection_timeout parameter, and outbout_connection_timeout parameters.
For example, if the value is 60 and the connection is not made successful within 60 seconds, then timeout happens. With your requirement, you can try these values by setting 10.i.e, 10 seconds.
For exact parameter name, u can google. Listener restart is required when a change happens in listener.ora to take effect.
1

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now