微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Hyperledger Fabric (1.4) EventHub 断开连接,没有详细错误

如何解决Hyperledger Fabric (1.4) EventHub 断开连接,没有详细错误

我们在 Amazon Managed Blockchain (AMB) 上运行 Hyperledger Fabric,最近我们决定从 1.2(长期以来 AMB 上唯一可用的版本)迁移到 1.4。我们使用 Java SDK 连接到 Hyperledger,在旧版本上没问题。重要的是,即使使用 HF 1.2 版,我们也使用 HF SDK 1.4.0 版,我们计划继续。

使用 1.4,基本没问题:我们可以执行主要活动,例如创建/加入频道、安装链代码查询/调用它们。但是,围绕事件的功能不起作用:当我们注册侦听器时它不起作用并且我们收到以下错误

2021-05-19 15:29:06.840 WARN 7 --- [ault-executor-0] org.hyperledger.fabric.sdk.EventHub : EventHub{id: 4,name: eventHub0,channelName: testchanone,url: grpcs://nd-ggqg7wmp4rgwjgab5cze4cjlba.m-vbe43tw4wbg2tgenuudpgzmfg4.n-4jqyvyxtlrc3hhe7u6jwxhsxge.managedblockchain.us-east-1.amazonaws.com:30004} terminated is false shutdown is false,retry count 601 has error UNAVAILABLE: io exception.
2021-05-19 15:29:06.841 WARN 7 --- [ault-executor-0] org.hyperledger.fabric.sdk.EventHub : EventHub{id: 4,url: grpcs://nd-ggqg7wmp4rgwjgab5cze4cjlba.m-vbe43tw4wbg2tgenuudpgzmfg4.n-4jqyvyxtlrc3hhe7u6jwxhsxge.managedblockchain.us-east-1.amazonaws.com:30004} :StatusRuntimeException Status Status{code=UNAVAILABLE,description=io exception,cause=io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: nd-ggqg7wmp4rgwjgab5cze4cjlba.m-vbe43tw4wbg2tgenuudpgzmfg4.n-4jqyvyxtlrc3hhe7u6jwxhsxge.managedblockchain.us-east-1.amazonaws.com/10.0.1.167:30004
2021-05-19T18:29:06.841+03:00   Caused by: java.net.ConnectException: Connection refused
2021-05-19T18:29:06.841+03:00   at sun.nio.ch.socketChannelImpl.checkConnect(Native Method)
2021-05-19T18:29:06.841+03:00   at sun.nio.ch.socketChannelImpl.finishConnect(SocketChannelImpl.java:716)
2021-05-19T18:29:06.841+03:00   at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
2021-05-19T18:29:06.841+03:00   at io.netty.channel.nio.AbstractNioChannel$AbstractNIoUnsafe.finishConnect(AbstractNioChannel.java:336)
2021-05-19T18:29:06.841+03:00   at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:685)
2021-05-19T18:29:06.841+03:00   at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632)
2021-05-19T18:29:06.841+03:00   at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549)
2021-05-19T18:29:06.841+03:00   at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511)
2021-05-19T18:29:06.841+03:00   at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
2021-05-19T18:29:06.841+03:00   at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
2021-05-19T18:29:06.841+03:00   at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
2021-05-19T18:29:06.841+03:00   at java.lang.Thread.run(Thread.java:748)
2021-05-19T18:29:06.841+03:00   }. Description io exception

最糟糕的部分是该错误没有说明导致它的具体原因:相同的配置和设置适用于 HF 1.2(并且它适用于其他功能),并且类似的设置适用于HF 1.4,我们很久以前将其用作自托管解决方案。

这是我们在创建频道时注册事件中心的方式:

...
        Properties channelProperties = new Properties();
        channelProperties.put("pemBytes",commonCaPem.getBytes());
        channelProperties.setProperty("sslProvider","openSSL");
        channelProperties.setProperty("negotiationType","TLS");
        channelProperties.put("grpc.NettyChannelBuilderOption.keepAliveTime",new Object[]{5L,TimeUnit.MINUTES});
        channelProperties.put("grpc.NettyChannelBuilderOption.keepAliveTimeout",new Object[]{60L,TimeUnit.SECONDS});
        channelProperties.put("grpc.NettyChannelBuilderOption.keepAliveWithoutCalls",new Object[]{true});

...

        ChannelConfiguration channelConfiguration = new ChannelConfiguration(
                    new File(generatedGenesisFile));
        byte[] channelConfigSigs = client.getChannelConfigurationSignature(channelConfiguration,adminUserContext);
        channel = client.newChannel(params.getChannelName(),orderers.stream().findAny()
                    .orElseThrow(() -> new invalidargumentexception("Could not find any orderer within configuration")),channelConfiguration,channelConfigSigs);

...

        List<String> eventHubList = new ArrayList<>(this.eventHubs);
        for (int i = 0; i < eventHubList.size(); i++) {
            EventHub hub = client.newEventHub("eventHub" + i,eventHubList.get(i),channelProperties);
            channel.addEventHub(hub);
        }

        for (Orderer orderer : orderers) {
            channel.addOrderer(orderer);
        }

        channel.initialize();
...

事件中心地址总是已知且正确的,我们会从 HF 节点配置中自动设置它们。

这是我们注册事件监听器的方式:

...
        String listenerHandle = container.getChannel().registerChaincodeEventListener(
                Pattern.compile(params.getChaincodeName() + ".*"),Pattern.compile(params.getQuotePattern() ? Pattern.quote(params.getPattern()) : params.getPattern()),(handle,blockEvent,chaincodeEvent) -> {
                    // actual event handler
                }
        );
...

如果您需要更多详细信息,我会添加它们。对于当前的问题,我不太确定处理它的正确方法

先谢谢你!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?