Enable canisters to make HTTP(S) requests

Updates to exchange_rate sample dapps (rust and motoko) in accordance with transform context change have been merged to examples repo.

7 Likes

@Severin @qijing_yu

Has a timeout been added to this from the IC?
I see the following error if my server takes more than 5 seconds to respond to a request.
I am fairly sure that I do not have any timeouts set on my end. Does the IC have one setup?

If so can we extent it to 60 seconds or turn it off?

“The http_request resulted into error. RejectionCode: SysFatal, Error: Timeout expired”

I found the docs about this…

the timeout period.

What is this and I think it needs to made higher…
If I put a timer on a result of 4 seconds after the first call it throws this error.

call 1: respond within 2 seconds.
call 2 though 8 : wait 4 seconds and then respond normally.

If I change the sleep to 2 seconds it works.

1 Like

@apotheosis

We do have a timeout of 3s for outstanding HTTP requests. This limit has not changed since we launched the feature and I agree it might be too low for certain applications.

We will discuss raising the request timeout and I will come back to you with an answer.

7 Likes

Good news. We decided to bump the timeout to 30s. If everything goes well it will be included in this week’s release candidate and rolled out next week!

7 Likes

Is there any update if http outcalls support IPv4. Like mentioned above some services only support IPv4. One I am currently working with is the rew relic logs api. Just wondering if there is an update, otherwise I have a work around this as well. Also the error I got was Error: Failet to do wallet call. Caused by: Failet to do wallet call. An error happened during the call: 4: Failed to connect: error trying to connect: tcp connect error: Network is unreachable (os error 101)

1 Like

I forwarded your question to the team.

Your error looks to be something with reaching the IC itself, not related to outcalls. Did you maybe forget to run dfx start or to select the right network (--network ic)?

1 Like

HTTPS outcalls to IPv4 destinations are currently not possible, and unfortunately, we have no clear vision as to when this will be possible. The core reason is that all the solutions we discussed were decided to be not secure enough. We are now discussing other solutions (for example, that node providers will provide NAT services), but that might be a long process until we have something working on mainnet.

4 Likes

Hi @yotam, forming a more expensive dual stack subnet would give the same guarantees I believe

Hi @janosroden , I answered in the other thread now. Sorry for my late reply.

1 Like

Are there any HTTP out POST examples?
For TLS auth, can a self-signed cert be used?

1 Like

I am not aware of existing public examples of HTTP POST with this feature. To be able to make a POST request, the remote web server should support some sort of idempotency deduplication of requests. For example using an idempotency-key header.

A self-signed certificate cannot be used. The target URL must have a valid certificate.

2 Likes

Fwiw, I am actively working on creating a code walk through tutorial with sample code for POST. I hope to be done in a few days (just need to wrap up the GET one first).

See my working draft: Http outcalls tutorial by dprats · Pull Request #1505 · dfinity/portal · GitHub

2 Likes

Follow up:

Here is the firs part on my rewriting of the HTTPS Outcalls documentation with sample code:

This includes a walk through of the sample code in Motoko and Rust for making GET requests.

The POST version is coming soon,

2 Likes

As I also mentioned in this response, I’m getting a timeout error (which is not related to the transformation function, see the mentioned response for details) when running in the local replica.
What could be the problem?

very odd, let me ping folks.

Follow up, i forgot to share this: https://internetcomputer.org/docs/current/developer-docs/integrations/https-outcalls/https-outcalls-post

4 Likes

Is there any update?