使用 springboot 集成 grpc 和 protobuf 时出现以下错误:
io.grpc.StatusRuntimeException: INTERNAL: Connection closed with unknown cause
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:141)
at io.grpc.stub.ServerCalls$1$1.onHalfClose(ServerCalls.java:148)
at io.grpc.internal.SerializingExecutor$TaskRunner.run(SerializingExecutor.java:152)
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:227)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:208)
原因:一系列 io.grpc 依赖版本不匹配
- 由于我前面使用io.grpc是1.4.0版本,然后请求一直报上面的错误,可以参考以下版本,我改成1.11.0之后就可以了
- 以下配置pom依赖可以借鉴:结果是可以正常连接的
com.google.protobuf
protobuf-java
3.6.1
com.googlecode.protobuf-java-format
protobuf-java-format
1.2
io.grpc
grpc-netty
1.11.0
io.grpc
grpc-protobuf
1.11.0
io.grpc
grpc-stub
1.11.0
io.grpc
grpc-all
1.11.0
io.netty
netty-all
4.1.22.Final
io.netty
netty-tcnative-boringssl-static
2.0.8.Final
net.devh
grpc-client-spring-boot-starter
1.3.0-RELEASE
com.google.api.grpc
proto-google-common-protos
1.0.0
org.xolstice.maven.plugins
protobuf-maven-plugin
0.5.0
com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier}
grpc-java
io.grpc:protoc-gen-grpc-java:1.11.0:exe:${os.detected.classifier}
${project.basedir}/src/main/proto
${project.basedir}/src/main/java
false
compile
compile
compile-custom