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.

Anyway to increase timeout on HTTP outcalls?

I’m not sure if it’s still the case, but when we discussed it in this thread back in March, there was no such option, and the maximum timeout was 30 seconds.

thanks for the update

It would be great to increase it for AI purposes. :pray:t2:

Even if we increase the timeout there still needs to be a limit because connections are shared resource.

What timeout will be acceptable ?

1 Like

New AI models can think for any amount of time, so I guess the maximum possible :slight_smile:. About 2 min seems to be ok for most queries due to UI/UX.

Any updates on this?

Any update?
It would be nice to have large timeouts available, putting into the Q and polling is not always an options