grpc 客户端调用问题
现象
- 已发现服务
用stub调用服务失败
客户端代码
package com.elvish.springcloud.service;
import org.springframework.stereotype.Component;
import io.grpc.Channel;
import net.devh.springboot.autoconfigure.grpc.client.GrpcClient;
import yjmyzz.grpc.study.dto.PersonList;
import yjmyzz.grpc.study.dto.QueryParameter;
import yjmyzz.grpc.study.service.DemoServiceGrpc;
@Component
public class TestGrpcService {
@GrpcClient("PROVIDER-USER")
private Channel serverChannel;
public PersonList getPersonList() {
DemoServiceGrpc.DemoServiceBlockingStub blockingStub = DemoServiceGrpc.newBlockingStub(serverChannel);
QueryParameter queryParameter = yjmyzz.grpc.study.dto.QueryParameter.newBuilder().setAgeStart(5).setAgeEnd(10)
.build();
return blockingStub.getPersonList(queryParameter);
}
}
日志
2018-01-29 10:01:33.707 INFO 12620 --- [ault-executor-0] n.d.s.a.g.c.DiscoveryClientNameResolver : Found grpc server PROVIDER-USER DESKTOP-ENB3GMH:7052
Exception in thread "grpc-default-executor-1" java.lang.InstantiationError: io.netty.util.internal.PriorityQueue
at io.netty.handler.codec.http2.WeightedFairQueueByteDistributor$State.<init>(WeightedFairQueueByteDistributor.java:243)
at io.netty.handler.codec.http2.WeightedFairQueueByteDistributor.<init>(WeightedFairQueueByteDistributor.java:58)
at io.netty.handler.codec.http2.DefaultHttp2RemoteFlowController.<init>(DefaultHttp2RemoteFlowController.java:65)
at io.netty.handler.codec.http2.DefaultHttp2RemoteFlowController.<init>(DefaultHttp2RemoteFlowController.java:56)
at io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder.<init>(DefaultHttp2ConnectionEncoder.java:52)
at io.grpc.netty.NettyClientHandler.newHandler(NettyClientHandler.java:146)
at io.grpc.netty.NettyClientHandler.newHandler(NettyClientHandler.java:125)
at io.grpc.netty.NettyClientTransport.newHandler(NettyClientTransport.java:251)
at io.grpc.netty.NettyClientTransport.start(NettyClientTransport.java:140)
at io.grpc.internal.ForwardingConnectionClientTransport.start(ForwardingConnectionClientTransport.java:45)
at io.grpc.internal.TransportSet.startNewTransport(TransportSet.java:222)
at io.grpc.internal.TransportSet.obtainActiveTransport(TransportSet.java:192)
at io.grpc.internal.ManagedChannelImpl$3.getTransport(ManagedChannelImpl.java:651)
at io.grpc.internal.ManagedChannelImpl$3.getTransport(ManagedChannelImpl.java:592)
at io.grpc.internal.RoundRobinServerList.getTransportForNextServer(RoundRobinServerList.java:83)
at io.grpc.util.RoundRobinLoadBalancerFactory$RoundRobinLoadBalancer$1.get(RoundRobinLoadBalancerFactory.java:148)
at io.grpc.internal.DelayedClientTransport$2.run(DelayedClientTransport.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)