#node.js #hyperledger-fabric #docker-swarm
#node.js #hyperledger-fabric #docker-swarm
Вопрос:
Если я размещаю свой микросервис на хост-компьютере, он работает должным образом, но если я размещаю то же самое в контейнере, я получаю эти ошибки:
2020-09-27T08:35:06.099Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Committer- name: orderer2.audit.blockit.co:9050, url:grpcs://localhost:9050, connected:false, connectAttempted:true
2020-09-27T08:35:06.099Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server orderer2.audit.blockit.co:9050 url:grpcs://localhost:9050 timeout:3000
2020-09-27T08:35:06.100Z - error: [DiscoveryService]: _buildOrderer[blockit] - Unable to connect to the discovered orderer orderer2.audit.blockit.co:9050 due to Error: Failed to connect before the deadline on Committer- name: orderer2.audit.blockit.co:9050, url:grpcs://localhost:9050, connected:false, connectAttempted:true
2020-09-27T08:35:09.108Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer2.blockit.co:9051, url:grpcs://localhost:9051, connected:false, connectAttempted:true
2020-09-27T08:35:09.109Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer2.blockit.co:9051 url:grpcs://localhost:9051 timeout:3000
2020-09-27T08:35:09.109Z - error: [DiscoveryService]: _buildPeer[blockit] - Unable to connect to the discovered peer peer2.blockit.co:9051 due to Error: Failed to connect before the deadline on Endorser- name: peer2.blockit.co:9051, url:grpcs://localhost:9051, connected:false, connectAttempted:true
2020-09-27T08:35:12.113Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer0.blockit.co:7051, url:grpcs://localhost:7051, connected:false, connectAttempted:true
2020-09-27T08:35:12.114Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0.blockit.co:7051 url:grpcs://localhost:7051 timeout:3000
2020-09-27T08:35:12.114Z - error: [DiscoveryService]: _buildPeer[blockit] - Unable to connect to the discovered peer peer0.blockit.co:7051 due to Error: Failed to connect before the deadline on Endorser- name: peer0.blockit.co:7051, url:grpcs://localhost:7051, connected:false, connectAttempted:true
2020-09-27T08:35:15.118Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Endorser- name: peer1.blockit.co:8051, url:grpcs://localhost:8051, connected:false, connectAttempted:true
2020-09-27T08:35:15.119Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer1.blockit.co:8051 url:grpcs://localhost:8051 timeout:3000
2020-09-27T08:35:15.119Z - error: [DiscoveryService]: _buildPeer[blockit] - Unable to connect to the discovered peer peer1.blockit.co:8051 due to Error: Failed to connect before the deadline on Endorser- name: peer1.blockit.co:8051, url:grpcs://localhost:8051, connected:false, connectAttempted:true
2020-09-27T08:35:15.145Z - error: [RoundRobinQueryHandler]: evaluate: message=Query failed. Errors: [], stack=FabricError: Query failed. Errors: []
at RoundRobinQueryHandler.evaluate (/app/microservice/node_modules/fabric-network/lib/impl/query/roundrobinqueryhandler.js:46:23)
at Transaction.evaluate (/app/microservice/node_modules/fabric-network/lib/transaction.js:278:49)
at FabricRepository.<anonymous> (/app/microservice/dist/services/blockchain-client.js:206:51)
at Generator.next (<anonymous>)
at fulfilled (/app/microservice/dist/services/blockchain-client.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5), name=FabricError
queryChaincode Error: Cannot query from blockchain: Query failed. Errors: []
at FabricRepository.<anonymous> (/app/microservice/dist/services/blockchain-client.js:213:23)
at Generator.throw (<anonymous>)
at rejected (/app/microservice/dist/services/blockchain-client.js:6:65)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
POST /fabric-service/queryChaincode 18184.858
Есть идеи, почему??
Комментарии:
1.
localhost
внутри контейнера относится к самому контейнеру. Вы уверены, что все указанные вами URL-адреса находятся внутри контейнера?2. Для моего профиля подключения я использую имя контейнера вместо IP. Что-то вроде:
"url": "grpcs://orderer0.audit.blockit.co:7050"
это должно быть решено правильно??
Ответ №1:
В выводе здесь вы можете увидеть
2020-09-27T08:35:15.119Z - error: [DiscoveryService]: _buildPeer[blockit] - Unable to connect to the discovered peer peer1.blockit.co:8051 due to Error: Failed to connect before the deadline on Endorser- name: peer1.blockit.co:8051, url:grpcs://localhost:8051, connected:false, connectAttempted:true
что он пытается подключиться к localhost: 8051. Поскольку localhost преобразуется в контейнер, в котором вы запускаете свое приложение, оно его не найдет. Вероятно, вы переходите на localhost, потому asLocalHost
что для вашего приложения установлено значение true
Вам необходимо установить для этого параметра значение false и убедиться, что ваше приложение в контейнере, в котором оно находится, может разрешать ожидаемые имена хостов, которые вы определили