Holochain Forum

Trouble running sim2h in HelloWorld

Hi guys.
Just looking to do some testing with sim2h and finding that the following command doesn’t work for me in nix-shell https://holochain.love:
sim2h_server -p 9001

I get a bash error:
bash: sim2h_server: command not found

any ideas how I can get around this?
cheers - sim

Ah yep it’s not in the holonix yet or maybe it is in the latest under a different command.
I will fix this asap.
For now you can use the public sim_2h server. It’s listed in the hello world tutorial. Then you don’t need to run the server.

hmm thanks Tom.
Have used the public server in conductor-config-alice/&bob.toml.
but still running into some issues.
I launch the both instances for bob and alice and they launch fine:

holochain -c conductor-config-bob.toml //same for alice.

Then I launch my programs on and try to connect via websocket on ws://localhost:3401 and 3402 but when I call a zome function from either side I get:

Encountered an error: connection refused
Enable a logger to see more information.

Initially when I run holochain -c conductor-config-alice I get:

Unlocking agent keys:
Unlocking key for agent 'alice': 
conductor: boot_from_config
Reading DNA from dist/signal_agent.dna.json
Reading DNA from dist/signal_agent.dna.json
conductor: build_conductor_api instance_id=test-instance, config=Configuration { agents: [AgentConfiguration { id: "alice", name: "Alice", public_address: "HcSciaDXrXkqxwv7gukMChvazIuscvcrk457t8n88cmo95en4sPCEdDKvj4ucja", keystore_file: "alice.key", holo_remote_key: None, test_agent: Some(true) }], dnas: [DnaConfiguration { id: "hc-run-dna", file: "dist/signal_agent.dna.json", hash: "QmcMbGaekBvA2i63m9sUgRHuzQ8U7mr7DdUH9ejhnddsbV", uuid: None }], instances: [InstanceConfiguration { id: "test-instance", dna: "hc-run-dna", agent: "alice", storage: Memory }], interfaces: [InterfaceConfiguration { id: "websocket-interface", driver: Websocket { port: 3401 }, admin: true, instances: [InstanceReferenceConfiguration { id: "test-instance", alias: None }] }], bridges: [], ui_bundles: [], ui_interfaces: [], logger: LoggerConfiguration { logger_level: "debug", rules: LogRules { rules: [LogRule { pattern: .*, exclude: true, color: None }, LogRule { pattern: ^lib3h, exclude: false, color: None }, LogRule { pattern: ^holochain, exclude: false, color: None }, LogRule { pattern: ^lib3h, exclude: false, color: None }] }, state_dump: false }, network: Some(Sim2h(Sim2hConfig { sim2h_url: "wss://sim2h.holochain.org:9000" })), persistence_dir: "/home/simwilso/.config/holochain/conductor", signing_service_uri: None, encryption_service_uri: None, decryption_service_uri: None, dpki: None, signals: SignalConfig { trace: false, consistency: false }, passphrase_service: Cmd }
Reading DNA from dist/signal_agent.dna.json
Reading DNA from dist/signal_agent.dna.json
Failed to load instance test-instance from storage: ErrorGeneric("State could not be loaded due to NoneError")
Initializing new chain...

OBSERVATION - one weird thing about the above is that the ‘public address’ listed for Alice differs from the one that was produced when I ran keygen.
It didn’t work with the keygen value in conductor-alice.toml but doesn’t work either when I enter the one above in conductor-alice.toml either.
I got the same mismatch for bob so updated with the public key listed for him for the same command above.

For Alice my conductor-config toml looks like this:

[[agents]]
id = 'alice'
name = 'Alice'

keystore_file = 'alice.key'
public_address = 'HcSciaDXrXkqxwv7gukMChvazIuscvcrk457t8n88cmo95en4sPCEdDKvj4ucja'

test_agent = true

[[dnas]]
file = 'dist/signal_agent.dna.json'
hash = 'QmcMbGaekBvA2i63m9sUgRHuzQ8U7mr7DdUH9ejhnddsbV'
id = 'hc-run-dna'

[[instances]]
agent = 'alice'
dna = 'hc-run-dna'
id = 'test-instance'

[instances.storage]
type = "memory"

[[interfaces]]
admin = true
id = 'websocket-interface'

[[interfaces.instances]]
id = 'test-instance'

[interfaces.driver]
port = 3401
type = 'websocket'

[network]
type = 'sim2h'
sim2h_url = 'wss://sim2h.holochain.org:9000'

My Websocket call from my program for Alice looks like this:

fn get_from_dht(_address: String) -> String {
        let json = serde_json::json!(
            {"id": "0",
             "jsonrpc": "2.0",
             "method": "call",
             "params": {"instance_id": "test-instance",
             "zome": "spot_signal",
             "function": "get_price",
             "args": {"address": _address}}
         });
        let (tx, rx) = channel();
        let tx1 = &tx;
        connect("ws://localhost:3401", |out| {
            // call an RPC method with parameters
            out.send(json.to_string()).unwrap();
            move |msg| {
                //println!("Got message: {:#?}", msg);
                tx1.send(msg).ok();
                out.close(CloseCode::Normal)
            }
        }).unwrap();
        rx.recv().unwrap().to_string() // set the value in the dht via websocket
    }
`get_from_dht("HcSCII4B5M3P3RjggrNo7fv8jhOtkoqd553a7FwcTBPhidyoeJUfiFS98gnwyti".to_string());`

Does anything stick out as wrong in my config above to you?
It all seems to work ok with the test hc conductor and my hc test scenarios with bob and alice go ok.

success.
My issue was 2 things.

  1. the ‘ID’ value in my websocket call needed updating.

    let json = serde_json::json!(
    {“id”: “0”,

change to:

let json = serde_json::json!(
            {"id": "alice",
  1. My address/key in conductor-alice.toml and bob needed to go back to the value generated in keygen not the value I had updated to above.

OBSERVATION
One interesting observation and trick to be careful of when calling from RUST is that each time you run the program and commit an entry the address seems to be different. i.e. the “Qm…” value below changes every time I run the program.

Got message: Text(
    "{\"jsonrpc\":\"2.0\",\"result\":\"{\\\"Ok\\\":\\\"QmXUVwcggZXmJJZhZwQ16Fe4dyjsPz9htfsYRDLntP4PTF\\\"}\",\"id\":\"alice\"}",
1 Like

Thank you for providing an update and letting us know this has been addressed. Thanks for sharing the tip!

1 Like

Glad you got it going. Sorry I was offline on a flight for a bit there.
I have also noticed the address’s are different but it hasn’t broken anything which is strange. I think @wollum noticed it the other day and thought it might be a hash of the address or something.

Hmm the entry address should definitely never change unless the data that you are committing does. ie. there might be a timestamp in your commit for example.

Is there anything in the data that you put into commit_entry that might be changing each time?

1 Like

no worries Tom.
Will have a look again tonight.
Mike G mentioned there might be possibly some issues being looked at in the public Sim2h server over the weekend. Is this the case?
I’m wondering as I just tried to spin up my conductor which was starting ok on Friday but now crashes.

Here’s what I see:

[nix-shell:~/Code/RedGrid-Alpha/Holochain/signal_agent]$ holochain -c conductor-config-alice.toml
Using config path: conductor-config-alice.toml
Reading DNA from dist/signal_agent.dna.json
Unlocking agent keys:
Unlocking key for agent 'alice': 
conductor: boot_from_config
Reading DNA from dist/signal_agent.dna.json
Reading DNA from dist/signal_agent.dna.json
conductor: build_conductor_api instance_id=test-instance, config=Configuration { agents: [AgentConfiguration { id: "alice", name: "Alice", public_address: "HcSciaDXrXkqxwv7gukMChvazIuscvcrk457t8n88cmo95en4sPCEdDKvj4ucja", keystore_file: "alice.key", holo_remote_key: None, test_agent: Some(true) }], dnas: [DnaConfiguration { id: "hc-run-dna", file: "dist/signal_agent.dna.json", hash: "QmcMbGaekBvA2i63m9sUgRHuzQ8U7mr7DdUH9ejhnddsbV", uuid: None }], instances: [InstanceConfiguration { id: "test-instance", dna: "hc-run-dna", agent: "alice", storage: Memory }], interfaces: [InterfaceConfiguration { id: "websocket-interface", driver: Websocket { port: 3401 }, admin: true, instances: [InstanceReferenceConfiguration { id: "test-instance", alias: None }] }], bridges: [], ui_bundles: [], ui_interfaces: [], logger: LoggerConfiguration { logger_level: "debug", rules: LogRules { rules: [LogRule { pattern: .*, exclude: true, color: None }, LogRule { pattern: ^lib3h, exclude: false, color: None }, LogRule { pattern: ^holochain, exclude: false, color: None }, LogRule { pattern: ^lib3h, exclude: false, color: None }] }, state_dump: false }, network: Some(Sim2h(Sim2hConfig { sim2h_url: "wss://sim2h.holochain.org:9000" })), persistence_dir: "/home/simwilso/.config/holochain/conductor", signing_service_uri: None, encryption_service_uri: None, decryption_service_uri: None, dpki: None, signals: SignalConfig { trace: false, consistency: false }, passphrase_service: Cmd }
Reading DNA from dist/signal_agent.dna.json
Reading DNA from dist/signal_agent.dna.json
Failed to load instance test-instance from storage: ErrorGeneric("State could not be loaded due to NoneError")
Initializing new chain...
WARNING! The git-hash of the runtime and the zome don't match.
Runtime hash: 9388be345fc13e5f2b62ab68f1df62691e6d2891
Zome hash: 
Successfully loaded 1 instance configurations
Starting instances...
Start all instances
Starting instance "test-instance"...
Starting interfaces...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Io Error: Address already in use (os error 98)"', src/libcore/result.rs:1051:5
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::continue_panic_fmt
   3: rust_begin_unwind
   4: core::panicking::panic_fmt
   5: core::result::unwrap_failed
   6: holochain_conductor_lib::conductor::base::Conductor::spawn_interface_thread
   7: holochain_conductor_lib::conductor::base::Conductor::start_all_interfaces
   8: holochain::main
   9: std::rt::lang_start::{{closure}}
  10: main
  11: __libc_start_main
  12: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I get the same issue trying to spin up alice or bob conductor where both where able to launch on Friday mid afternoon. I don’t recall changing anything in the conductor configs and weirdly on friday for a period alice was panicing every time but I was able to launch bob… but now both panic.

I’m going to have a play and see if I have different luck on a local sim2h instance but just wondering if there’s anything weird happening with the public one or if it could be something else.

BTW - have a great trip to Barcelona and cheers for all the great help! Just so you know you have also now ruined me by showing me that metabox site!! Their machines look so nice! Might have to look at an early christmas .present :slight_smile:

just to add here, hc package and hc run spin up ok. It’s just when I run the conductor version that I’m seeing error.
Here’s my conductor config if that helps:

[[agents]]
id = 'alice'
name = 'Alice'

keystore_file = 'alice.key'
public_address = 'HcSCII4B5M3P3RjggrNo7fv8jhOtkoqd553a7FwcTBPhidyoeJUfiFS98gnwyti'

test_agent = true

[[dnas]]
file = 'dist/signal_agent.dna.json'
hash = 'QmcMbGaekBvA2i63m9sUgRHuzQ8U7mr7DdUH9ejhnddsbV'
id = 'hc-run-dna'

[[instances]]
agent = 'alice'
dna = 'hc-run-dna'
id = 'test-instance'

[instances.storage]
type = "memory"

[[interfaces]]
admin = true
id = 'websocket-interface'

[[interfaces.instances]]
id = 'test-instance'

[interfaces.driver]
port = 3401
type = 'websocket'

[network]
type = 'sim2h'
sim2h_url = 'wss://sim2h.holochain.org:9000'

Yes, could be related. There were some issues on Thursday, but Nico reported that this has been resolved.

" sim2h.holochain.org is currently not working! The ec2 instance has changed its IP address, which means the DNS entry is broken. New IP is 18.195.19.114 . You can put that into Holoscape ( wss://18.195.19.114:9000 ) until the DNS is fixed.

Latest: sim2h.holochain.org back up again

1 Like

This is just because something else is using the port. Just change the port on the conductor.