HTTP outcalls: HTTP request error. RejectionCode: SysFatal, Error: Timeout expired

How do I extend the default timeout for a particular HTTP outcall, if that’s even possible?

juno-satellite-1 | 2024-02-29 15:08:25.058166501 UTC: [Canister jx5yt-yyaaa-aaaal-abzbq-cai] HTTP request error. RejectionCode: SysFatal, Error: Timeout expired

2 Likes

The default connect timeout is 2s (creating a TCP connection to the destination) and the default request timeout is 30s (entire request which includes reading the response). The timeout is configurable in the JSON config for the adapter.

{
  "http_connect_timeout_secs": X,
  "http_request_timeout_secs": Y,
  ...
}

Since you seem to hit the request timeout of 30s, which already is very generous, the issue is probably with the service you are trying to reach.

What’s the timeout on mainnet, is that 30 seconds as well?

With “in the JSON config for the adapter”, you mean the ic-https-outcalls-adapter - i.e. following right?

function create_config() {
  cat << EOF > "$CONFIG_PATH"
{
  "incoming_source": {
    "Path": "$SOCK_PATH"
  },
  "socks_proxy": "socks5://notaproxy:1080",
  "logger": {
    "level": "error"
  },
  "http_request_timeout_secs": "30"
}
EOF
}

Definitely not, OpenAI requires time. :wink:

Update: I added a 25sec limit in my prompt and it worked out. So yes, it’s definitely the timeout.

Yes the timeout on mainnet is 30s. The JSON seems correct to me.

I added a 25sec limit in my prompt and it worked out. So yes, it’s definitely the timeout.

Nice that they have this option. If really necessary we could also bump the timeout limit. The feature was release pre ChatGPT :wink:

Good to know, thanks.

Unfortunately, it’s not really an option but, a piece of text I added in the prompt which worked yesterday but, not today anymore :melting_face:

I hope I’ll find a solution for my demo, maybe I can revisit my prompt…

It’s not mandatory for my use case, I’m just building a demo.

However, to my knowledge, it’s not fully uncommon in serverless to have an option to define the timeout per request. For example Google Firebase HTTP function options (see timeoutSeconds: https.HttpsOptions interface  |  Cloud Functions for Firebase).

Example of application:

const runtimeOpts = {
  timeoutSeconds: 300,
};

exports.openai = functions.runWith(runtimeOpts).https.onRequest(app);

Is there any plan to extend http_request outcalls to support similar option?

Is there any plan to extend http_request outcalls to support similar option?

We discussed at some point adding an http timeout field to the HTTP outcalls request. This timeout would be applied to the actual HTTP request to the specified server. We can support it if this is wanted by the community.

1 Like

Good to know as well. Thanks for the answers.