连接配置文件

Hyperledger Composer使用连接配置文件连接到运行时。

创建连接配置文件

1.创建一个名为connection.json的新文件,其中包含Hyperledger Fabric v1.0的以下信息。}

为Hyperledger Fabric v1.0创建连接配置文件,使用以下格式:

  1. {
  2. "type": "hlfv1",
  3. "orderers": [
  4. { "url" : "grpc://localhost:7050" }
  5. ],
  6. "ca": { "url": "http://localhost:7054",
  7. "name": "ca.org1.example.com"
  8. },
  9. "peers": [
  10. {
  11. "requestURL": "grpc://localhost:7051",
  12. "eventURL": "grpc://localhost:7053"
  13. }
  14. ],
  15. "keyValStore": "${HOME}/.composer-credentials",
  16. "channel": "composerchannel",
  17. "mspID": "Org1MSP",
  18. "timeout": "300"
  19. }
  20. If you are connecting to Hyperledger Fabric v1.0 and are not using TLS or if you don't need the trustedRoots and verify options of the Certificate Authority definition you can use the following simplified connection profile:
  21. _Please note: The simplified version of the connection profile will only work if the relevant certificate authority has no name defined. If the certificate authority has a defined name, it must be specified._
  22. {
  23. type: 'hlfv1',
  24. name: 'hlfv1org1',
  25. orderers: [
  26. 'grpc://localhost:7050'
  27. ],
  28. ca: {
  29. url: 'http://localhost:7054',
  30. name: 'ca.org1.example.com'
  31. },
  32. peers: [
  33. {
  34. requestURL: 'grpc://localhost:7051',
  35. eventURL: 'grpc://localhost:7053'
  36. },
  37. ],
  38. channel: 'composerchannel',
  39. mspID: 'Org1MSP',
  40. timeout: '300',
  41. };
  • name 是用于引用连接配置文件的名称,是必需的。

  • type定义你将连接的Hyperledger Fabric的版本。连接到Hyperledger Fabric v1.0应是hlfv1

  • ca定义要连接的Hyperledger Fabric证书颁发机构的URL。如果你的证书颁发机构需要一个名称,则必须将其定义为ca以上第一个Hyperledger Fabric v1.0示例中所示的属性。

  • trustedRootsverify证书颁发机构的选项在这里描述https://fabric-sdk-node.github.io/global.html#TLSOptions

  • orderers是描述要与之通信的排序节点的对象数组。在orderers中,你必须定义每个排序节点的url。如果你通过TLS进行连接,则连接配置文件中的所有url属性都必须以grpcs://开头,并且还必须在cert属性中包含正确的TLS证书。

  • peers是描述要与之通信的peer的对象数组。每个人都peer必须有一个定义requestURL和定义eventURL。如果你使用TLS进行连接,则每个peer都必须在cert属性中具有正确的TLS证书。

  • hostnameOverride 仅在测试环境中使用,当服务器证书的主机名与运行服务器进程的实际主机端点不匹配时,应用程序可以通过将此属性设置为服务器证书主机名的值来解决客户端TLS验证失败的问题。

  • 每个cert属性的实例都应该是包含PEM格式的TLS证书字符串。可以在每个cert属性中放置多个证书。

    1. -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----
  • mspid是您的组织的成员服务提供商ID。它与你将用于与业务网络进行交互的登记ID相关联。

  • timeout是一个可选属性,用于控制向peer和orderer发出的每个请求的超时时间。请注意,有些命令可能会发出几个连续的请求,超时将分别应用于每个请求。

  • globalCert定义了在没有指定cert属性的情况下,用于所有peer和orderer的TLS证书。如果指定了一个cert属性,那么它仅覆盖相应peer或orderer的globalCert属性。

  • maxSendSize是一个可选属性,它定义了发送给orderers和peer的出站grpc消息的大小限制。该值以兆字节定义。如果没有设置,grpc会设置一个默认值。设置此属性为-1会导致无大小限制。

  • maxRecvSize是一个可选属性,用于定义从订购者和同伴接收到的入站grpc消息的大小限制。该值以兆字节定义。如果没有设置,grpc会设置一个默认值。设置此属性为-1会导致无大小限制。