My HTTP outcall does not work, any clue what I am missing?
let body = gpt_body_generation(download_url);
let body_json = serde_json::to_string(&body).map_err(|e| e.to_string())?;
// Looks good: {"model":"dall-e-3","n":1,"prompt":"A cute baby sea otter","size":"1024x1024"}
print(format!("--------------------> {}", body_json));
let request_headers = vec![
HttpHeader {
name: "Content-Type".to_string(),
value: "application/json".to_string(),
}
];
let request = CanisterHttpRequestArgument {
url: "https://us-central1-xxxxx-ipv6.cloudfunctions.net/openai/".to_string(),
method: HttpMethod::POST,
body: Some(body_json.into_bytes()),
max_response_bytes: None,
transform: None,
headers: request_headers,
};
match http_request_outcall(request, 10_000_000_000).await {
Ok((response,)) => {
let str_body = String::from_utf8(response.body)
.expect("Transformed response is not UTF-8 encoded.");
Ok(())
}
Err((r, m)) => {
let message = format!("HTTP request error. RejectionCode: {:?}, Error: {}", r, m);
Err(message)
}
}
Same in JS works fine - i.e. my proxy to use IPv6 for the call works fine:
const response = await fetch(
`https://us-central1-xxxxxx-ipv6.cloudfunctions.net/openai/`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'dall-e-3',
prompt: 'A cute baby sea otter',
n: 1,
size: '1024x1024'
})
}
);
if (!response.ok) {
console.error('Response not ok!', response);
return;
}
const result = await response.json();
console.log('OK', result);
The error just says the following:
juno-satellite-1 | Feb 28 18:24:10.182 INFO s:wl44v-wrkxf-oha2r-ip3hg-hzodh-7eu6u-c6jmc-mpupc-i3hw3-vfedz-lae/n:m62ac-gftga-hraen-72o6n-tggo4-wwypg-xaji3-brl6g-jlgu6-lu2jw-7qe/ic_replicated_state/subnet_call_context_manager Received the response for HttpRequest with callback id 34 from CanisterId(jx5yt-yyaaa-aaaal-abzbq-cai)
juno-satellite-1 | 2024-02-28 18:07:59.778000965 UTC: [Canister jx5yt-yyaaa-aaaal-abzbq-cai] HTTP request error. RejectionCode: SysTransient, Error: error trying to connect: Connection refused (os error 111)