Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-30
6
Medium Priority
?
5,902 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 78

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 35

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 78

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 78

Assisted Solution

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

Accepted Solution

by:
Anand earned 1400 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

916 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