I bet I’ve got something incorrectly in my custom Docker container but, did not found the solution so far. Does the following error message resulting of an HTTP Outcalls rings a bell to anyone?
Failed to add canister http request to queue BrokenConnection
I’m using the sample provided in the example repo. Basically a copy/paste minus adding enough cycles to http_request
call.
//2. SETUP ARGUMENTS FOR HTTP GET request
// 2.1 Setup the URL and its query parameters
type Timestamp = u64;
let start_timestamp: Timestamp = 1682978460; //May 1, 2023 22:01:00 GMT
let seconds_of_time: u64 = 60; //we start with 60 seconds
let host = "api.pro.coinbase.com";
let url = format!(
"https://{}/products/ICP-USD/candles?start={}&end={}&granularity={}",
host,
start_timestamp.to_string(),
start_timestamp.to_string(),
seconds_of_time.to_string()
);
// 2.2 prepare headers for the system http_request call
//Note that `HttpHeader` is declared in line 4
let request_headers = vec![
HttpHeader {
name: "Host".to_string(),
value: format!("{host}:443"),
},
HttpHeader {
name: "User-Agent".to_string(),
value: "exchange_rate_canister".to_string(),
},
];
// This struct is legacy code and is not really used in the code. Need to be removed in the future
// The "TransformContext" function does need a CONTEXT parameter, but this implementation is not necessary
// the TransformContext(transform, context) below accepts this "context", but it does nothing with it in this implementation.
// bucket_start_time_index and closing_price_index are meaninglesss
let context = Context {
bucket_start_time_index: 0,
closing_price_index: 4,
};
//note "CanisterHttpRequestArgument" and "HttpMethod" are declared in line 4
let request = CanisterHttpRequestArgument {
url: url.to_string(),
method: HttpMethod::GET,
body: None, //optional for request
max_response_bytes: None, //optional for request
transform: None, //optional for request
headers: request_headers,
};
match http_request_out(request, 2_000_000_000).await {
Ok((response,)) => {
Ok(())
},
Err((r, m)) => {
let message =
format!("The http_request resulted into error. RejectionCode: {r:?}, Error: {m}");
Err(message)
}
}
I start the replica with the subnet feature enabled.
./target/ic-starter --replica-path ./target/replica \
--http-port "$REPLICA_PORT" \
--state-dir "$STATE_REPLICA_DIR" \
--create-funds-whitelist '*' \
--subnet-type application \
--ecdsa-keyid Secp256k1:juno_test_key \
--log-level info \
--use-specified-ids-allocation-range \
--consensus-pool-backend lmdb \
--subnet-features canister_sandboxing \
--subnet-features http_requests