无法启动Hyperledger Explorer:Peer URL匹配失败问题求助
解决Hyperledger Explorer启动时"Failed to find a peer matching the url"错误
从你的日志和配置文件来看,问题出在Hyperledger Explorer的config.json配置结构错误,导致它无法正确识别你的Fabric网络中的peer和channel。下面是具体的排查和修复步骤:
核心问题分析
- Peer配置键名错误:你的
config.json里把peer命名为peer1,但实际你的Fabric网络中运行的是peer0.org1.example.com,Explorer无法匹配到对应的peer节点。 - 缺少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的实际主机名一致,避免身份匹配问题。
后续验证步骤
- 停止正在运行的Explorer服务:
cd /home/ubuntu/blockchain-explorer npm stop - 清理旧的客户端存储,避免缓存干扰:
rm -rf /tmp/fabric-client-kvs - 重新启动Explorer服务:
npm start - 查看日志,如果没有再出现
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
相关产品推荐
相关产品推荐

