You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法启动Hyperledger Explorer:Peer URL匹配失败问题求助

解决Hyperledger Explorer启动时"Failed to find a peer matching the url"错误

从你的日志和配置文件来看,问题出在Hyperledger Explorer的config.json配置结构错误,导致它无法正确识别你的Fabric网络中的peer和channel。下面是具体的排查和修复步骤:

核心问题分析

  1. Peer配置键名错误:你的config.json里把peer命名为peer1,但实际你的Fabric网络中运行的是peer0.org1.example.com,Explorer无法匹配到对应的peer节点。
  2. 缺少Channel关联配置:配置中没有明确指定composerchannel对应的peer信息,导致代码抛出Cannot read property 'composerchannel' of undefined的错误。

修正后的config.json配置

替换你的config.json为以下内容,我已经修正了上述问题:

{
  "network-config": {
    "Org1": {
      "name": "Org1",
      "mspid": "Org1MSP",
      "peers": {
        "peer0.org1.example.com": {
          "requests": "grpc://localhost:7051",
          "events": "grpc://localhost:7053",
          "server-hostname": "peer0.org1.example.com"
        }
      },
      "admin": {
        "key": "/home/ubuntu/fabric-dev-servers/fabric-scripts/hlfv11/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore",
        "cert": "/home/ubuntu/fabric-dev-servers/fabric-scripts/hlfv11/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts"
      }
    }
  },
  "host": "localhost",
  "port": "8080",
  "channel": "composerchannel",
  "channels": {
    "composerchannel": {
      "peers": {
        "peer0.org1.example.com": {}
      }
    }
  },
  "keyValueStore": "/tmp/fabric-client-kvs",
  "eventWaitTime": "30000",
  "users": [
    {
      "username": "admin",
      "secret": "adminpw"
    }
  ],
  "pg": {
    "host": "127.0.0.1",
    "port": "5432",
    "database": "fabricexplorer",
    "username": "hppoc",
    "passwd": "password"
  },
  "license": "Apache-2.0"
}

关键修改点说明

  • 将原来的peer1改为peer0.org1.example.com,并放在peers对象下,和Composer的connection.json中的peer名称保持一致。
  • 添加了channels配置块,明确composerchannel关联的peer节点,解决代码找不到channel的问题。
  • 确保server-hostname和peer的实际主机名一致,避免身份匹配问题。

后续验证步骤

  1. 停止正在运行的Explorer服务:
    cd /home/ubuntu/blockchain-explorer
    npm stop
    
  2. 清理旧的客户端存储,避免缓存干扰:
    rm -rf /tmp/fabric-client-kvs
    
  3. 重新启动Explorer服务:
    npm start
    
  4. 查看日志,如果没有再出现Failed to find a peer matching the url和Cannot read property 'composerchannel' of undefined的错误,说明配置修复成功,此时可以访问http://localhost:8080查看Explorer。

额外检查项

  • 确认PostgreSQL数据库fabricexplorer已创建,且用户hppoc有读写权限:
    sudo -u postgres psql -c "CREATE DATABASE fabricexplorer;"
    sudo -u postgres psql -c "CREATE USER hppoc WITH PASSWORD 'password';"
    sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE fabricexplorer TO hppoc;"
    
  • 确认Fabric网络的peer0.org1.example.com确实在运行,端口7051处于监听状态:
    netstat -tulpn | grep 7051
    

内容的提问来源于stack exchange,提问作者ulu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:04:22