我正在运行一个NodeJS服务器,其中包含以下代码以连接到Hyperledger Runtime:
const BusinessNetworkConnection = require("composer-client")
.BusinessNetworkConnection;
this.businessNetworkConnection = new BusinessNetworkConnection();
this.CONNECTION_PROFILE_NAME = "hlfv1";
this.businessNetworkIdentifier = "testNetwork";
this.businessNetworkConnection
.connect(
this.CONNECTION_PROFILE_NAME,
this.businessNetworkIdentifier,
"admin",
"adminpwd"
)
.then(result => {
this.businessNetworkDefinition = result;
console.log("BusinessNetworkConnection: ", result);
})
.then(() => {
// Subscribe to events.
this.businessNetworkConnection.on("events", events => {
console.log("**********business event received**********", events);
});
})
// and catch any exceptions that are triggered
.catch(function(error) {
throw error;
});
我看到在result
对象中建立连接后返回的数据,并且它是已部署的正确网络数据。
但是,当我提交事务并通过生成的REST API发出请求时,我的服务器看不到任何事件。在Historian中,我可以看到事件被发出。我还应该做些什么来查看我的交易所发出的事件?
答案 0 :(得分:2)
我尝试了同样的测试,我可以接收事件。我比较了我的测试代码和你的测试代码,我发现了以下不同之处:
this.bizNetworkConnection.on('事件'
this.bizNetworkConnection.on('事件'
我希望它有所帮助。