Is there a hello world or simple chat app for RSM?

Thanks, I’ll try that! Once the server is running, my next question would be how do I interact with it? Can I do an HTTP POST (or websocket command) with the exact payload that I would have used in holochain redux? If not, could you spell it out as a CURL command, or point me to a UI or script (or docs) for a simple server API call?

Thanks for all the great help! :pray:

As far as I know everything is websockets, and I’d say it’s quite difficult to do from the command line alone.

I think the best think for you to do is look over the conductor api repo (https://github.com/holochain/holochain-conductor-api) and look at examples from the UI code from other projects (I think all the ones listed above contain some of that). Careful about which version of the conductor api library they are using though because that has changed quite a lot lately.

1 Like

Hm, with the latest version of @holochain-open-dev/holochain-run-dna (0.2.1) I get this:

$ npm start

> @ start /Users/harlan/code/elemental-chat
> npx @holochain-open-dev/holochain-run-dna elemental-chat.dna.gz

Error: ProcessAlreadyExists
Error: could not connect to holochain conductor, please check that a conductor service is running and available at ws://localhost:1234
    at WebSocket.socket.onerror (/Users/harlan/code/elemental-chat/node_modules/@holochain-open-dev/holochain-run-dna/dist/main.js:7996:28)
    at WebSocket.onError (/Users/harlan/code/elemental-chat/node_modules/ws/lib/event-target.js:140:16)
    at WebSocket.emit (events.js:210:5)
    at ClientRequest.<anonymous> (/Users/harlan/code/elemental-chat/node_modules/ws/lib/websocket.js:579:15)
    at ClientRequest.emit (events.js:210:5)
    at Socket.socketErrorListener (_http_client.js:406:9)
    at Socket.emit (events.js:210:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Conductor ready.

Hum yeah… What git commit have you compiled your holochain binary with?

$ git show
commit 1524c61928ae00b477e720045b7d5a75fb413535
Date:   Thu Nov 26 17:02:50 2020 -0500

Hum can you try installing globally and then running the command again?

npm i -g @holochain-open-dev/holochain-run-dna

OK, coming back to this one after some time with a fresh approach:

I am using multipass to create an ubuntu 20 headless VM.

I did the standard nix setup:

sh <(curl -L https://nixos.org/nix/install)
nix-shell  https://holochain.love

Then, taking a cue from the elemental-chat CI, I installed a specific holochain version:

nix-shell  https://holochain.love  --command "cargo install --force holochain --git https://github.com/holochain/holochain.git --rev 60da73e79397cbe21280edf9a3062ae325f0bf9a"

Then, within the nix-shell, as described in the elemental-chat readme, I did:

CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown
dna-util -c elemental-chat.dna.workdir

(Note: technically, I had to clean up my old build first with git clean -Xdf)

Then I made the package.json we discussed earlier in this thread:

{
  "scripts": {
    "start": "holochain-run-dna elemental-chat.dna.gz"
  },
  "devDependencies": {
    "@holochain-open-dev/holochain-run-dna": "^0.3.2"
  }
}

and did:

npm install
npm start

That appears to be working:

> holochain-run-dna elemental-chat.dna.gz

#lair-keystore-ready#
#lair-keystore-version:0.0.1-alpha.10#
Using config file at path:  /tmp/tmp.aZNzDFsbO7/tmp-144465-GQx7Fz0K8JiP/config.yaml

###HOLOCHAIN_SETUP###
###ADMIN_PORT:38071###
###HOLOCHAIN_SETUP_END###
Conductor ready.
(-m FLAG OFF) Generating single agent pub key for all apps.
Successfully installed app on port 8888

Now, over in the elemental-chat-ui repo, I had to hack the src/store/index.js a bit to allow me to access the HC server running on an IP address (from multipass VM) instead of localhost:

const WEB_CLIENT_HOST = process.env.VUE_APP_WEB_CLIENT_HOST || "localhost";

const WEB_CLIENT_URI =
  isHoloHosted() || isHoloSelfHosted()
    ? `wss://${window.location.hostname}/api/v1/ws/`
    : `ws://${WEB_CLIENT_HOST}:${WEB_CLIENT_PORT}`;

(I will PR this once I get it all working.)

I started the client, plugging in the IP address:

VUE_APP_WEB_CLIENT_HOST=[MULTIPASS IP] VUE_APP_INSTALLED_APP_ID=elemental-chat-test npm run serve:develop

The client seems to work fine, but the websocket is failing. Screenshot:

Maybe I have to do something over the admin port? Not super clear on that part, the only indications I’ve found say:

  • make sure holochain is running with a configuration that includes an admin interface websocket port
  • send a properly encoded InstallApp command over the websocket
  • be sure to ActivateApp and AttachAppInterface as well.

@guillemcordoba do you think this is the missing piece? Are there any instructions that spell this step out more clearly if so?

… or a code example of how to do this within any app?

Awesome :smiley:

So actually elemental-chat is a bit tricky to get going, because they are targeting the holo environment as well as the “development” environment, and that means we need to be careful here. Basically it’s a matter of having the holochain’s port and installed_app_id aligned with the one in the frontend.

They are running the UI/DNA like this: GitHub - holochain/elemental-chat-ui: A Vue.js + Vuetify + Vuex web app for Elemental Chat DNA.. But careful because this is using the new hc tool and that has just been merged, so nix-shell holochain.love won’t work with this. Overall I think it’s pretty convoluted… I got it working once but this seems to have changed.

I’m in the process of upgrading everything I have currently in open-dev, which I think would be much easier to setup. Would you want me to ping you once I have some example module that works and has good instructions?

@harlan you can see this module, which is already updated and working: https://github.com/holochain-open-dev/file-storage/blob/main/dev-setup.md

You just checkout and run this

nix-shell .
cd ui
npm install
npm start

Let me know if you have any problems if you give it a go.

Thanks, trying that! Thanks also for the info on how elemental chat is set up, makes a lot more sense now.

FYI for anyone trying to use multipass, my basic incantations are:

brew install multipass
multipass help
multipass help launch    # this will explain all the flags used in the next line
multipass launch -d 20G -m 2G -n hcdev1  # tweak as appropriate
cd ~ && multipass mount code hcdev1:code   # mount your ~/code dir as ~/code
multipass shell hcdev1 # shell into instance
multipass restart hcdev1  # if things get stuck
multipass info  # shows mount points, etc
multipass list   # shows all instances

More info here: https://multipass.run/docs

2 Likes

Multipass, great stuff! Followed your instructions and am back online again on macOS Mojave. Everything builds, thanks! 🧘‍♂️

1 Like

@guillemcordoba when I follow these instructions, plus modifying localhost:8888 -> [VM IP]:8888 in the start-ui script and also in ui/demo/index.html, the UI starts correctly but there seems to be nothing running on [VM IP]:8888. Screenshot:

Hm, thought I, perhaps I need to do as the readme suggests, and follow the instructions on the zome readme page.

But when I get to running the first of these commands:

hc s call register-dna --path zome/file_storage.dna.workdir/file-storage-test.dna
hc s call install-app <RESULT_HASH_OF_PREVIOUS_COMMAND>

There is no output, so not sure where to get the hash for the second command.

Here is my transcript:

[nix-shell:~/file-storage/zome]$ CARGO_TARGET=target cargo build --release --target wasm32-unknown-unknown

[snip]

   Compiling file_storage v0.0.1 (/home/ubuntu/file-storage/zome/zomes/file_storage)
    Finished release [optimized] target(s) in 1m 54s

[nix-shell:~/file-storage/zome]$ hc dna pack file_storage.dna.workdir
Wrote bundle /home/ubuntu/file-storage/zome/file_storage.dna.workdir/file-storage-test.dna

[nix-shell:~/file-storage/zome]$ hc s call register-dna --path zome/file_storage.dna.workdir/file-storage-test.dna

[nix-shell:~/file-storage/zome]$ echo $?
0

@guillemcordoba any ideas? :pray:

@kristofer excellent, glad to hear it! I’m pretty happy with multipass, though I have to restart VMs regularly.

Curious what app(s) you got running? I’m still working on file-storage and elemental-chat, so far without full success.

I am looking to upgrade Key-value storage to hdk 0.0.1, and possibly also the sample app I made - Holochain / GraphQL Todo. But I’ll probably pause for a few days until Tryorama works again, see this post:

1 Like

Ohhh yes… So I think this is actually the same issue I found with the docker images. Holochain binds itself to 127.0.0.1, not to localhost, which makes it not accessible from the outside. I had to do a socat port forwarding to be able to call it, which you can see in the compository dockerfile.

Ah interesting, thanks. Maybe we could change it to optionally bind to 0.0.0.0, at least for dev usage. Just a musing… will look at socat too :stuck_out_tongue_winking_eye:

1 Like

@guillemcordoba that worked! Thanks for all your patient support.

For the record, I changed the ports from 8888 -> 8889 in the ui/package.json start-ui script and also in ui/demo/index.html , so it expects to hit holochain on port 8889, then did:

npm start &
socat tcp-l:8889,fork,reuseaddr tcp:127.0.0.1:8888 

– just copied from your example, no deep understanding of socat here, yet…
And now I am using the upload demo as expected.

1 Like