0

holochain -c hcconfig.toml当使用生产导体(即使用)运行 holochain 应用程序时,

如何从前端查询实例@holochain/hc-web-client (v0.5.0)

我尝试过:

import { connect } from "@holochain/hc-web-client";

const opts = {
  url: "ws://localhost:8888"
};
const hConn: HoloConn = await connect(opts);
const { call } = hConn;
const info = await call("info", "instances")();
console.log({ info });

这似乎与开发指挥(即hc run)一起工作,

在此处输入图像描述

但是当我切换到生产指挥时,它会在同一个地方返回一个空数组。

为了与生产指挥一起工作,我需要改变什么吗?


这是我的指挥配置:

bridges = []

[[agents]]
id = "alice"
name = "alice"
keystore_file = "/tmp/hc/keys/alice.key"
public_address = "HcSCj9wvVKj7ryhm9ttRansEX5Zyk5ac4QOFK59sowZzrw36s6NuTSeDtn6oiui"

[[agents]]
id = "bob"
name = "bob"
keystore_file = "/tmp/hc/keys/bob.key"
public_address = "HcSCj7r458cQcxSkfwSa3S6myv7Mv5ukwSc4IP6fg8yYwoevVbFnY4dAO4e3dyz"


[[dnas]]
id = "tender"
file = "dist/hc-201906.dna.json"


[[instances]]
id = "instance_alice"
agent = "alice"
dna = "tender"
    [instances.storage]
    path = "/tmp/hc/instance_alice.storage"
    type = "file"
[[instances]]
id = "instance_bob"
agent = "alice"
dna = "tender"
    [instances.storage]
    path = "/tmp/hc/instance_bob.storage"
    type = "file"




[[interfaces]]
id = "websocket interface"
admin = true
    [interfaces.driver]
    port = 8888
    type = "websocket"

[logger]
type = "debug"
    [[logger.rules.rules]]
    color = "red"
    exclude = false
    pattern = "^err/"

    [[logger.rules.rules]]
    color = "white"
    exclude = false
    pattern = "^debug/dna"

    [[logger.rules.rules]]
    exclude = false
    pattern = ".*"
4

1 回答 1

0

问题出在导体配置中:

在 websocket 接口定义中,缺少的是通过该接口公开实例的链接:

    [[interfaces.instances]]
    id = "instance_alice"
    [[interfaces.instances]]
    id = "instance_bob"

完整的配置如下所示:

bridges = []

[[agents]]
id = "alice"
name = "alice"
keystore_file = "/tmp/hc/keys/alice.key"
public_address = "HcSCjoZM6f4C3pe684umUf65KWVu8oqecZhwYeySVaxytowvFN777VbQxyCyopa"

[[agents]]
id = "bob"
name = "bob"
keystore_file = "/tmp/hc/keys/bob.key"
public_address = "HcSCIE6abINr5ojy7o8xp7fjMJjG4au67GU34QQjbkHg6prdhfYo9XyjVymsrdr"


[[dnas]]
id = "tender"
file = "dist/hc-201906.dna.json"


[[instances]]
id = "instance_alice"
agent = "alice"
dna = "tender"
    [instances.storage]
    path = "/tmp/hc/instance_alice.storage"
    type = "file"
[[instances]]
id = "instance_bob"
agent = "alice"
dna = "tender"
    [instances.storage]
    path = "/tmp/hc/instance_bob.storage"
    type = "file"




[[interfaces]]
id = "interface_websocket"
admin = true
    [interfaces.driver]
    port = 8888
    type = "websocket"
    [[interfaces.instances]]
    id = "instance_alice"
    [[interfaces.instances]]
    id = "instance_bob"

# -----------  UI  -----------

[[ui_bundles]]
id = "bundle_ui"
root_dir = "./web-ui/build"

[[ui_interfaces]]
id = "ui_interface"
bundle = "bundle_ui"
port = 8908
dna_interface = "interface_websocket"

# -----------  Logging  -----------

[logger]
type = "debug"
    [[logger.rules.rules]]
    color = "red"
    exclude = false
    pattern = "^err/"

    [[logger.rules.rules]]
    color = "white"
    exclude = false
    pattern = "^debug/dna"

    [[logger.rules.rules]]
    exclude = false
    pattern = ".*"
于 2019-07-08T16:47:24.097 回答