Browse Source

Fixed grpc over ssl

pull/3957/head
Volodymyr Babak 6 years ago
parent
commit
c71ba1f245
  1. 5
      common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

5
common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

@ -76,8 +76,7 @@ public class EdgeGrpcClient implements EdgeRpcClient {
Consumer<DownlinkMsg> onDownlink,
Consumer<Exception> onError) {
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(rpcHost, rpcPort)
.keepAliveTime(keepAliveTimeSec, TimeUnit.SECONDS)
.usePlaintext();
.keepAliveTime(keepAliveTimeSec, TimeUnit.SECONDS);
if (sslEnabled) {
try {
builder.sslContext(GrpcSslContexts.forClient().trustManager(new File(Resources.getResource(certResource).toURI())).build());
@ -85,6 +84,8 @@ public class EdgeGrpcClient implements EdgeRpcClient {
log.error("Failed to initialize channel!", e);
throw new RuntimeException(e);
}
} else {
builder.usePlaintext();
}
channel = builder.build();
EdgeRpcServiceGrpc.EdgeRpcServiceStub stub = EdgeRpcServiceGrpc.newStub(channel);

Loading…
Cancel
Save