https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/faq/connect.html

Important: 前置说明

1. jdk版本支持

JavaSDK原则上支持从jdk 1.8到jdk 15的OracleJDKOpenJDK,但中间有部分版本禁用或者不支持secp256k1曲线,会导致sdk与节点之间握手失败,请首先检查当前使用的jdk是否支持secp256k1曲线,目前已经覆盖测试的jdk版本如下,推荐大家使用:

  • OracleJDK:

    • 1.8.0_141

    • 1.8.0_202

    • 11.0.2

    • 14.0.2

    • 15.0.2

  • OpenJDK:

    • 11.0.2

    • 14.0.2

    • 15.0.2

  • jdk下载链接:

    • OracleJDK官网:

      • https://www.oracle.com/java/technologies/downloads/archive/

    • 国内镜像:

      • http://www.codebaoku.com/jdk/jdk-oracle.html

      • http://www.codebaoku.com/jdk/jdk-openjdk.html

若使用的jdk禁用了secp256k1曲线(注意: 如果jdk不支持secp256k1曲线,不适用该方法),可以参考 #issue 470通过手动修改java.security属性的方式重新启用secp256k1曲线.

2. JavaSDK版本说明

JavaSDK 2.8.1优化了sdk连接失败的日志和报错提示,欢迎使用2.8.1及以上版本的sdk,更便于定位错误问题。

maven方式

<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.53.Final</version>
</dependency>
<dependency>
<groupId>org.fisco-bcos.java-sdk</groupId>
<artifactId>fisco-bcos-java-sdk</artifactId>
<version>2.9.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

gradle方式

dependencies {
compile ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:2.9.0')
}
configurations.all {
resolutionStrategy {
force 'io.netty:netty-all:4.1.53.Final'
}
}


排查步骤

JavaSDK启动失败时会有类似于如下的异常信息:

* TRACE INFORMATION:
----------------------------
====> STEP1: try to connect nodes with ecdsa context...
<==== STEP1 Result: try to connect nodes with ecdsa context failed for cert missing
* Missed certificates: [conf/ca.crt,conf/sdk.crt,conf/sdk.key,]
currentPath: /Users/octopus/fisco/asset-app/dist ----------------------------
====> STEP2: connect nodes with ecdsa context failed, try to connect nodes with sm-context...
<==== STEP2 Result: connect with sm context failed for cert missing.
* Missed certificates:
[conf/gm/gmca.crt,conf/gm/gmsdk.crt,conf/gm/gmsdk.key,conf/gm/gmensdk.key,conf/gm/gmensdk.crt,]
currentPath: /Users/octopus/fisco/asset-app/dist
----------------------------
<====> Error: try to connect nodes with both ecdsa and sm context failed <====>
<====> Please refer to github issue: https://github.com/FISCO-BCOS/java-sdk/issues/536
<====> Please refer to fisco-docs: https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/faq/connect.html
----------------------------
* FISCO BCOS Java SDK Version: 2.8.1
* Support secp256k1 : true
* Java Version : 15.0.2
* JDK Disabled NamedCurves : null
* JDK DisableNative Option : null
* OS Name : Mac OS X
* OS Arch : x86_64
* OS Version : 10.16
* JVM Version : 15.0.2+7-27
* JVM Vendor : Oracle Corporation
* JVM Vendor URL : https://java.oracle.com/

不同的项目对错误的处理方式不同,这段错误信息可能会重复显示多次,用户从最后的RACE INFORMATION:开始排查即可。

step1:检查是否拷贝证书

若sdk同时抛出下面两个错误,说明没有拷贝证书,需要将证书拷贝到src/main/resources/conf子目录或conf子目录下:

<==== STEP1 Result: try to connect nodes with ecdsa context failed for cert missing
* Missed certificates: xxxxxx <==== STEP2 Result: connect with sm context failed for cert missing.
* Missed certificates: xxxxxx

证书拷贝步骤可参考FISCO BCOS文档:搭建第一个区块链网络


step2: 检查节点是否启动或者SDK与节点之间网络是否连通

若SDK抛出如下错误,说明SDK与节点之间网络不连通,或者节点没有启动:

* TRACE INFORMATION:
----------------------------
====> STEP1: try to connect nodes with ecdsa context...
<==== STEP1-1: Load certificates for ecdsa context success...
<==== connect nodes failed, reason:
Failed to connect to all the nodes!
* connect to 127.0.0.1:20200 failed! Please make sure the nodes have been started, and the network between the SDK and the nodes are connected normally.reason: Connection refused: /127.0.0.1:20200 * connect to 127.0.0.1:20201 failed! Please make sure the nodes have been started, and the network between the SDK and the nodes are connected normally.reason: Connection refused: /127.0.0.1:20201

通过ps命令检查节点进程是否启动:

# 到节点所在机器运行ps命令
ps aux |grep -i fisco-bcos

通过telnet命令检查sdk到节点的网络是否连通:

telnet ${节点ip} ${节点channel_listen_port}

注意:channel_listen_port,在节点config.ini配置文件中:

$ cat node0/config.ini | egrep channel_listen
channel_listen_ip=0.0.0.0
channel_listen_port=20208


step3: 检查证书是否拷贝正确

保证项目打开java-sdk日志,在日志中grepSSLHandshakeExceptionValidatorException或者secp256k1`:

 grep -iE 'SSLHandshakeException|ValidatorException|secp256k1' sdk.log

若输出如下错误说明放置在SDK中的证书错误,需要重新配置证书:

...
sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
Caused by: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
Caused by: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem
Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
Suppressed: javax.net.ssl.SSLHandshakeException: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Caused by: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem
...

Note: 若这里输出disable secp256k1的日志,说明握手失败是由于jdk禁用secp256k1曲线导致的,可继续转step4排查。


step4: 非国密区块链-检查jdk是否支持secp256k1曲线

Note: 国密区块链且采用国密SSL连接可跳过本检查步骤。

FISCO BCOS非国密默认采用secp256k1曲线,但随着jdk版本的升级,secp256k1曲线逐渐被弃用(因此2.9.0版本在保证向下兼容的同时,非国密连接采用RSA曲线),对于采用非国密SSL的区块链(节点的config.ini配置sm_channel_crypto=false),在SDK日志中grep关键字disable.*secp256k1

cat sdk.log|grep -i 'disable.*secp256k1'

若有如下输出,说明当前jdk不支持secp256k1曲线,则需要参考#issue 470 手动修改java.security属性启用secp256k1曲线或者替换到支持secp256k1曲线的jdk版本:

Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Algorithm constraints check failed on disabled algorithm: secp256k1
Caused by: java.security.cert.CertPathValidatorException: Algorithm constraints check failed on disabled algorithm: secp256k1
Caused by: java.security.cert.CertPathValidatorException: Algorithm constraints check failed on disabled algorithm: secp256k1
Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Algorithm constraints check failed on disabled algorithm: secp256k1
Caused by: java.security.cert.CertPathValidatorException: Algorithm constraints check failed on disabled algorithm: secp256k1
Caused by: java.security.cert.CertPathValidatorException: Algorithm constraints check failed on disabled algorithm: secp256k1

Note: jdk曲线的变更均会记录在release notes中,具体可参考 https://www.oracle.com/java/technologies/javase/jdk-relnotes-index.html。


step5: 国密区块链 && 启用国密SSL连接 — 检查netty库是否冲突

Note: 非国密区块链或者国密区块链但没有开启国密SSL连接可跳过本检查步骤。

FISCO BCOS国密区块链若开启国密SSL连接(节点的config.ini配置sm_channel_crypto=true),可能因为netty库冲突,导致sdk连接节点失败。

Java SDK默认的netty库版本是netty-4.1.53.Final,Spring-boot等其他组件若和Java SDK一起使用,会引入高版本或者低版本的netty,从而因netty冲突导致sdk连接节点失败。

对于本情况,可在SDK日志中grep关键字NoSuchMethodErrornetty关键字:

cat sdk.log|grep -E 'NoSuchMethodError|netty'

若输出如下日志,说明netty库冲突:(这里的示例是spring采用了高版本的netty-4.1.60.Final,java-sdk不支持该版本的netty)。

	at io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1113) ~[netty-all-4.1.60.Final.jar:4.1.60.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262) ~[netty-all-4.1.60.Final.jar:4.1.60.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248) ~[netty-all-4.1.60.Final.jar:4.1.60.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:241) ~[netty-all-4.1.60.Final.jar:4.1.60.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405) ~[netty-all-4.1.60.Final.jar:4.1.60.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:262) ~[netty-all-4.1.60.Final.jar:4.1.60.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:248) ~[netty-all-4.1.60.Final.jar:4.1.60.Final]
... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bcosSDK' defined in class path resource [applicationContext.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.fisco.bcos.sdk.BcosSDK]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: 'void io.netty.handler.ssl.OpenSslContext.<init>(java.lang.Iterable, io.netty.handler.ssl.CipherSuiteFilter, io.netty.handler.ssl.ApplicationProtocolConfig, long, long, int, java.security.cert.Certificate[], io.netty.handler.ssl.ClientAuth, java.lang.String[], boolean, boolean)'
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.fisco.bcos.sdk.BcosSDK]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: 'void io.netty.handler.ssl.OpenSslContext.<init>(java.lang.Iterable, io.netty.handler.ssl.CipherSuiteFilter, io.netty.handler.ssl.ApplicationProtocolConfig, long, long, int, java.security.cert.Certificate[], io.netty.handler.ssl.ClientAuth, java.lang.String[], boolean, boolean)'
Caused by: java.lang.NoSuchMethodError: 'void io.netty.handler.ssl.OpenSslContext.<init>(java.lang.Iterable, io.netty.handler.ssl.CipherSuiteFilter, io.netty.handler.ssl.ApplicationProtocolConfig, long, long, int, java.security.cert.Certificate[], io.netty.handler.ssl.ClientAuth, java.lang.String[], boolean, boolean)'

此时参考#issue 332,指定netty版本为4.1.53解决冲突,大致写法如下:

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.53.Final</version>
</dependency> <dependency>
<groupId>org.fisco-bcos.java-sdk</groupId>
<artifactId>fisco-bcos-java-sdk</artifactId>
<version>2.9.0</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
</exclusions>
</dependency>


spring + java-sdk 构建应用,强烈推荐参考应用spring-boot-crud:

SDK连接节点失败排查思路的更多相关文章

  1. Flink on YARN(下):常见问题与排查思路

    Flink 支持 Standalone 独立部署和 YARN.Kubernetes.Mesos 等集群部署模式,其中 YARN 集群部署模式在国内的应用越来越广泛.Flink 社区将推出 Flink ...

  2. Linux 服务器性能问题排查思路

    一个基于 Linux 操作系统的服务器运行的同时,也会表征出各种各样参数信息.通常来说运维人员.系统管理员会对这些数据会极为敏感,但是这些参数对于开发者来说也十分重要,尤其当你的程序非正常工作的时候, ...

  3. 使用ping网络工具编写Shell脚本程序实现网络连接故障初步排查

    在学习ping命令的时候,突发奇想:为何不使用ping命令对网络连接故障进行排查? 具体思路: 1. ping  127.0.0.1 (虚拟网卡地址)以检查主机的TCP/IP协议栈是否正常. 2. p ...

  4. 超长可视化指南!带你理清K8S部署的故障排查思路,让bug无处遁形

    本文将帮助你厘清在Kubernetes中调试 deployment的思路.下图是完整的故障排查思路,如果你想获得更清晰的图片,请在公众号后台(RancherLabs)回复"troublesh ...

  5. NO11 SSH故障排查思路和netstat命令

    本章知识相关考试:1.企业场景面试题:Linux系统如何优化?2.企业场景面试题:SSH服务连不上,如何排查?记住回答技巧: 1 ping  2 telnet 客户端ssh工具:SecureCRT,x ...

  6. android SDK Manager 上载失败

    android SDK Manager 下载失败如题,利用android SDK Manager 无法下载各个版本的SDK,是最近无法连接上谷歌的服务器吗?我用了网上说的在C:\WINDOWS\sys ...

  7. Android SDK Manager 更新失败的解决方法

    Android SDK Manager 更新失败的解决方法 原文地址 最近使用Android SDK Manager 更新Android SDK tools 发现经常更新失败,获取不到更新信息: Fe ...

  8. 系统运行缓慢,CPU 100%,以及Full GC次数过多问题的排查思路

    前言 处理过线上问题的同学基本上都会遇到系统突然运行缓慢,CPU 100%,以及Full GC次数过多的问题.当然,这些问题的最终导致的直观现象就是系统运行缓慢,并且有大量的报警. 本文主要针对系统运 ...

  9. 关于流量升高导致TIME_WAIT增加,MySQL连接大量失败的问题

    有个应用就是每次都会去查一个接口,接口返回用户的信息数据,从而展现不同的页面效果.大致流程如下 应用APP(电信)-> memcache ->电信custom接口 ->master- ...

  10. windows应急响应入侵排查思路

    0x00 前言 ​ 当企业发生黑客入侵.系统崩溃或其它影响业务正常运行的安全事件时,急需第一时间进行处理,使企业的网络信息系统在最短时间内恢复正常工作,进一步查找入侵来源,还原入侵事故过程,同时给出解 ...

随机推荐

  1. 【墨天轮专访第四期】华为云GaussDB苏光牛:发挥生态优势,培养应用型DBA

    导读: 随着5G互联网时代的来临,各行各业对于数据库的依赖程度也在逐步提高.由于国内在数据库行业的发展起步较晚,数据库的市场份额长期被Oracle,微软等美国公司所控制.但是伴随着国内IT技术栈的不断 ...

  2. 2021年8月国产数据库排行榜:TiDB稳榜首,达梦返前三,Kingbase进十强,各厂商加速布局云生态

    8月份的国产数据库流行度排行榜新鲜出炉.本月共有139个数据库参与了排名. 先来看看排行榜前五名.PingCAP的TiDB分数连续第二个月上涨,总分达到630.21,以136.48的分数差拉开了与第二 ...

  3. MYSQL存储过程-练习4 loop循环

    MYSQL存储过程-练习4 loop循环 创建存储过程 1 DELIMITER $$ 2 3 CREATE PROCEDURE `sp_loop`() 4 BEGIN 5 DECLARE i INT; ...

  4. mongo对文档中数组进行过滤的三种方法

    前言 在mongo中数据类型有很多种,常见的包括: 数据类型 例子 描述 String { "x" : "foot" } 字符串.存储数据常用的数据类型.在 M ...

  5. 阿里云服务器安装mysql镜像

    新创建的服务器首先需要创建安全组,开放端口然后重启服务器 登陆远程服务器,具体操作步骤如下 #拉取镜像 docker pull mysql:5.7 #查看镜像是否拉取到 docker images # ...

  6. 使用 KubeSphere 应用商店 5 分钟内快速部署 JuiceFS

    作者:朱唯唯,尹珉 JuiceFS 简介 JuiceFS 是为海量数据设计的分布式文件系统,使用对象存储来做数据持久化,避免重复造轮子,还能大大降低工程复杂度,让用户专注解决元数据和访问协议部分的难题 ...

  7. VMware使用Ubuntu20.04时发生屏幕闪烁

    问题:VMware使用Ubuntu20.04时发生屏幕闪烁 分析:这是由于虚拟机里面的显示器不支持3D加速问题导致的 解决方法:关闭虚拟机 → 左上角菜单 → 虚拟机 → 设置 → 显示器 → 取消勾 ...

  8. 🥳重磅更新!Fluent Editor 开源富文本支持 LaTeX 可编辑公式啦~

    你好,我是 Kagol,个人公众号:前端开源星球. Fluent Editor 是一个基于 Quill 2.0 的富文本编辑器,在 Quill 基础上扩展了丰富的模块和格式,框架无关.功能强大.开箱即 ...

  9. CodeForces Round 898 (div 4) H题解析

    CodeForces Round 898 (div 4)H. Mad  City 大致思路    对于有n条边和n个点,说明这个图里面只有一个环 并且两人同时开始和结束移动,所以可以得到当Valeri ...

  10. NZOJ 模拟赛7

    T1 字符串 小X十分热爱学习.有一天,他刚学完"漂亮的k字符串"的概念:给定长度为n的字符串和整数k,k能整除n,如果该字符串满足以下两个条件: s是一个回文串,即对于任意1≤i ...