Skip to Main Content
  • Questions
  • Second run of calling webservice using UTL_HTTP fails with ORA-12535: TNS:operation timed out

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Shivanand.

Asked: April 01, 2020 - 7:36 am UTC

Last updated: April 02, 2020 - 3:40 am UTC

Version: 12.2

Viewed 1000+ times

You Asked

Hi Tom,

Please help me in addressing this issue.

I am using the below procedure to call HTTPS wsdl, this works fine for the first time when calling this procedure on SQL prompt logging into DB server(AIX) via Putty.
But fails when I try to execute the same again on the same SQL prompt and error out with below exception. I had to logout from OS and login again to make it work.

ORA-12535: TNS:operation timed out
ORA-06512: at "USER1.SHOW_HTML_FROM_URL", line 36
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1127
ORA-06512: at "USER1.SHOW_HTML_FROM_URL", line 13
ORA-06512: at line 1

Is there any setting I am missing in the code to make the next HTTP connection working? OR any other settings at the DB end we should be checking with DBA team.
Kindly help. as this will be running in a batch mode and there are couple of APIs calls in the same session.

The URL used here is :
https://hostname.test.com:9443/configuration_rules?wsdl

create or replace PROCEDURE show_html_from_url (
  p_url  IN  VARCHAR2,
  p_username IN VARCHAR2 DEFAULT NULL,
  p_password IN VARCHAR2 DEFAULT NULL
) AS

 l_http_request   UTL_HTTP.req;
  l_http_response  UTL_HTTP.resp;
  l_text           VARCHAR2(32767);
BEGIN
  -- Make a HTTP request and get the response.
utl_http.set_wallet('file:/opt/oracle/wallet', null); -- wallet is created with --nologin option
  utl_http.set_detailed_excp_support(TRUE);
  l_http_request  := UTL_HTTP.begin_request(p_url);
 
  -- Use basic authentication if required.
  IF p_username IS NOT NULL and p_password IS NOT NULL THEN
    UTL_HTTP.set_authentication(l_http_request, p_username, p_password);
  END IF;
  l_http_response := UTL_HTTP.get_response(l_http_request);
 
  -- Loop through the response.
  BEGIN
    LOOP
      UTL_HTTP.read_text(l_http_response, l_text, 32766);
      DBMS_OUTPUT.put_line (l_text);
    END LOOP;
  EXCEPTION
    WHEN UTL_HTTP.end_of_body THEN
      UTL_HTTP.end_response(l_http_response);
  END;
EXCEPTION
  WHEN OTHERS THEN
    UTL_HTTP.end_response(l_http_response);
    RAISE;
END show_html_from_url;

and Connor said...

That's not something I've ever seen.

Your code looks fine. Perhaps try an explicit UTL_HTTP.END_REQUEST call at the end of the routine ?

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library