Skip to content

[Question] How to connect light-client-js to local dev node? #232

@tea2x

Description

@tea2x

https://github.com/nervosnetwork/ckb-light-client?tab=readme-ov-file#how-to-run

I followed above section, assuming it's similar to light-client.

Here's my dev node local_node_info:

{
  "jsonrpc": "2.0",
  "result": {
    "active": true,
    "addresses": [
      {
        "address": "/ip4/0.0.0.0/tcp/8115",
        "score": "0x1"
      }
    ],
    "connections": "0x0",
    "node_id": "QmWU9CWxK6yjzcfAbnUL8xdr54DSbYpwLDYew3gJm6WgGJ",
    "protocols": [
      {
        "id": "0x64",
        "name": "/ckb/syn",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x67",
        "name": "/ckb/relay3",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x79",
        "name": "/ckb/filter",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x66",
        "name": "/ckb/tim",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x78",
        "name": "/ckb/lightclient",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x6e",
        "name": "/ckb/alt",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x2",
        "name": "/ckb/identify",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x0",
        "name": "/ckb/ping",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x1",
        "name": "/ckb/discovery",
        "support_versions": [
          "2",
          "2.1",
          "3"
        ]
      },
      {
        "id": "0x3",
        "name": "/ckb/flr",
        "support_versions": [
          "2",
          "3"
        ]
      },
      {
        "id": "0x4",
        "name": "/ckb/disconnectmsg",
        "support_versions": [
          "2",
          "3"
        ]
      }
    ],
    "version": "0.114.0 (0c8711e 2024-02-29)"
  },
  "id": 1
}

Here's how i start the light client js:

      await this.client.start(
        { type: "TestNet", config },
        secretKey as Hex,
        "info",
        "wss"
      );

Here's the light-client-js network config:

# chain = "mainnet"
# chain = "testnet"
# chain = "your_path_to/dev.toml"
chain = "../../../NERVOS/ckb-dev-chain/specs/dev.toml"

[store]
path = "data/store"

[network]
path = "data/network"

listen_addresses = ["/ip4/0.0.0.0/tcp/8110"]
### Specify the public and routable network addresses
# public_addresses = []

# Node connects to nodes listed here to discovery other peers when there's no local stored peers.
# When chain.spec is changed, this usually should also be changed to the bootnodes in the new chain.
bootnodes = [
    "/ip4/127.0.0.1/tcp/8115/p2p/QmWU9CWxK6yjzcfAbnUL8xdr54DSbYpwLDYew3gJm6WgGJ"
]

### Whitelist-only mode
# whitelist_only = false
### Whitelist peers connecting from the given IP addresses
# whitelist_peers = []

### Enable `SO_REUSEPORT` feature to reuse port on Linux, not supported on other OS yet
# reuse_port_on_linux = true

max_peers = 125
max_outbound_peers = 1
# 2 minutes
ping_interval_secs = 120
# 20 minutes
ping_timeout_secs = 1200
connect_outbound_interval_secs = 15
# If set to true, try to register upnp
upnp = false
# If set to true, network service will add discovered local address to peer store, it's helpful for private net development
discovery_local_address = false
# If set to true, random cleanup when there are too many inbound nodes
# Ensure that itself can continue to serve as a bootnode node
bootnode_mode = false

[rpc]
# Light client rpc is designed for self hosting, exposing to public network is not recommended and may cause security issues.
# By default RPC only binds to localhost, thus it only allows accessing from the same machine.
listen_address = "127.0.0.1:9000"

When I use /ip4/127.0.0.1/tcp/8115/p2p/QmWU9CWxK6yjzcfAbnUL8xdr54DSbYpwLDYew3gJm6WgGJ as the boot node in the network config I get:

WebSocket connection to 'wss://127.0.0.1:8115/' failed:

What's the probable cause to this connection failure?
Or any suggestion to achieve connecting ckb-light-client-js to a local dev node?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions