Problem connecting to a running conductor (app id not found)

Hello.
I’m new to Holochain and started with the tutorials recommended in the Developer section:
https://github.com/holochain/happ-build-tutorial

Everything worked out as described and the conductor was up and running the hApp

$ hc sandbox call 1 list-apps
hc-sandbox: List Apps: [InstalledAppInfo { installed_app_id: "test-app", cell_data: [InstalledCell { cell_id: CellId(DnaHash(uhC0kUIew8M-K2ZAUmh1NywzP4Emo050Zmp5oaldzSf2aGsq09SFp), AgentPubKey(uhCAkomVJo2MHkqqSPmovoQOSvOztAMrGqfKmHyd7lsbPGg_ZuTgF)), cell_nick: "sample-slot" }], status: Running }]

Then I went through this tutorial to connect to my hApp:
https://github.com/holochain/happ-client-call-tutorial

I used the Rust example code:

use hdk::prelude::{
    holochain_serial,
    holochain_zome_types::zome::{FunctionName, ZomeName},
    ExternIO, SerializedBytes,
};
use holochain_conductor_api::ZomeCall;
use holochain_conductor_api_rust::AppWebsocket;
use serde::*;

const WS_URL: &str = "ws://localhost:8888";
const H_APP_ID: &str = "test-app";
const ZOME_NAME: &str = "numbers";
const FN_NAME: &str = "add_ten";

// custom data we want to pass the hApp
#[derive(Serialize, Deserialize, SerializedBytes, Debug, Clone)]
struct ZomeInput {
    number: i32,
}

// custom data we want back from the hApp
#[derive(Serialize, Deserialize, SerializedBytes, Debug, Clone)]
pub struct ZomeOutput {
    other_number: i32,
}

pub async fn call() -> Result<ZomeOutput, String> {
    // connect to a running holochain conductor
    // (there needs to be a running holochain conductor!)
    let mut app_ws = AppWebsocket::connect(WS_URL.to_string())
        .await
        .or(Err(String::from("Could not connect to conductor")))?;
    let app_info_result = app_ws
        .app_info(H_APP_ID.to_string())
        .await
        .or(Err(String::from("Could not get app info")))?;
    let app_info = match app_info_result {
        None => return Err(String::from("no app info found")),
        Some(app_info) => app_info,
    };
    let cell_id = app_info.cell_data[0].as_id().to_owned();

    let payload = ZomeInput { number: 10 };
    // you must encode the payload to standardize it
    // for passing to your hApp
    let encoded_payload = ExternIO::encode(payload.clone())
        .or(Err(String::from("serialization of payload failed")))?;

    // define the context of the request
    let api_request = ZomeCall {
        cell_id: cell_id.clone(),
        zome_name: ZomeName::from(String::from(ZOME_NAME)),
        fn_name: FunctionName::from(String::from(FN_NAME)),
        payload: encoded_payload,
        cap: None,
        provenance: cell_id.clone().agent_pubkey().to_owned(),
    };

    // make the request
    let encoded_api_response = app_ws
        .zome_call(api_request)
        .await
        .map_err(|e| {
            println!("{:?}", e);
            e
        })
        .or(Err(String::from("zome call failed")))?;

    // you must decode the payload from
    // the standarized format its returned as
    let result: ZomeOutput = encoded_api_response
        .decode()
        .or(Err(String::from("deserialization failed")))?;

    Ok(result)
}

#[tokio::main]
async fn main() {
    match call().await {
        Ok(s) => println!("Result of the call: {:#?}", s),
        Err(e) => println!("Got an error: {:?}", e),
    };
}

Compiling and running gave this error:

$ cargo run
   Compiling happ-client-call-tutorial v0.1.0 (/home/stefan/dev/rust/holochain/happ-client-call-tutorial)
   Finished dev [unoptimized + debuginfo] target(s) in 22.85s
   Running target/debug/happ-client-call-tutorial
Got an error: "Could not get app info"

The conductor says it’s running app with id “test-app” and the example is trying to connect to H_APP_ID = “test-app”,

My questions here:
Why does the connection fail?
How can one debug such a situation?

Thanks in advance,
stefan

1 Like

Unfortunately it was a nonstarter for me since my App ID was used by a Store app and therefore could not be deleted.

However, I discovered through some experimentation that I could solve the problem by manually editing the exiting App ID. It turns out that Xcode is really picky about the name of the ID, and not just the bundle ID.

Thank you very much

AYM