Forum OpenACS Q&A: Re: NaviServer stops serving connections when slow external api calls pile up.

FYI: We are using the call:

ad_try {
set result [ns_http run -method GET -headers $request_headers -expire $timeout $url]
} trap NONE {result options} {

} trap CHILDSTATUS {result options} {

} on error {result options} {

} finally {

}

However, the 'expire $timeout' option does not seem to work in all situations and then the thread gets stuck waiting for the ns_http return

To add a little more information to this issue, the issue we are seeing is when the request to:

set timeout 500
set result [ns_http run -method GET -headers $request_headers -expire $timeout $url]

returns with a result that is trapped in the NONE case and contains result and error_info values of

:     status:
:     result: ssl connect failed: error:00000000:lib(0):func(0):reason(0)
:     error_info: ssl connect failed: error:00000000:lib(0):func(0):reason(0)
:        while executing
:    "ns_http run -method GET -headers $request_headers -expire $timeout $url"
:        ("::try" body line 4)

When this happens, the call to ns_http does not expire after the 500ms but can take anywhere from 20 seconds to 2 minutes to return.

The biggest questions we have are:

Why does ns_http not expire in these cases? And, is there a way to get it to so that a problem with the target site will not affect our site?

Thanks for any ideas you may have with this,

-Tony Kirkham