API Connect

Meet Business SLA with Enhanced timeouts

By Ozair Sheikh posted Fri February 21, 2020 05:33 PM

Many businesses have strict SLAs with vendors or third-party companies. For example, one of our customers need to stay within milliseconds to support Apple Pay. When SLA are not met, it can have serious financial consequences, so its critical that your API solution provides extensibility to meet strict business controls.

Fortunately, GatewayScript provides access to a rich set of JavaScript functions which allow you to enforce millisecond timeout. You can use this code as part of a GatewayScript policy within DataPower or API Connect. The default Invoke policy in API Connect only supports seconds so you can modify the Invoke policy to use GatewayScript if you need to support milliseconds.
const urlopen = require('urlopen');
async function main() {
var open_options = {
// the target URL
target: 'http://backend.something/v2/5e4d491a2d0000339ec0dd15',
// method is optional, default is GET
method: 'GET',
timeout: 1
//reject on 10ms
const response = await urlOpen( open_options, 10);
console.error('response: %j',response)
function urlOpen(open_options, timeout) {
return new Promise(function(resolve, reject) {
urlopen.open(open_options, function (error, response) {
if (error) {
console.error("openCallback error: " + error.errorMessage+"\n");
else {
setTimeout(reject, timeout);