I am using GRPC to connect to a service. Sometimes calls are successful, while sometimes it fails with exception Received unexpected EOS on DATA frame from server.
I am not able to find the reason to this. Following is code making call:
public class LmServiceClientImpl implements LmServiceClient {
LMAttributeServiceGatewayGrpc.LMAttributeServiceGatewayBlockingStub lmAttributeServiceGatewayBlockingStub;
@Autowired
@Qualifier("lmservice")
private ManagedChannel managedChannel;
@PostConstruct
public void init() {
lmAttributeServiceGatewayBlockingStub = LMAttributeServiceGatewayGrpc.newBlockingStub(managedChannel);
}
@Override
public LMAttributesApiProto.IpAttributeResponse getAttributes(
final LMServiceProto.IpEntityRequest ipEntityRequest
) {
try {
log.info("Querying DLM service with payload {}",
JsonFormat.printer().print(ipEntityRequest.toBuilder()));
} catch (final Exception e) {
// No action required
}
final LMAttributesApiProto.IpAttributeResponse ipAttributeResponse =
lmAttributeServiceGatewayBlockingStub.getAttributes(ipEntityRequest);
try {
log.info("Response from DLM service {}", JsonFormat.printer().print(ipAttributeResponse.toBuilder()));
} catch (final Exception e) {
// No action required
}
return ipAttributeResponse;
}
}
The ManagedChannel is getting autowired from following class:
public class LmServiceGrpcConfig {
@Value("${lm.server.host}")
private String host;
@Value("${lm.server.port}")
private int port;
@Bean("lmservice")
public ManagedChannel prepareManagedChannel() {
return NettyChannelBuilder.forAddress(host, port)
.usePlaintext()
.build();
}
}
Client dependencies:
def grpcVersion = '1.26.0'
compile group: 'io.netty', name: 'netty-all', version: '4.1.44.Final'
compile group: 'io.grpc', name: 'grpc-protobuf', version: "${grpcVersion}"
compile group: 'io.grpc', name: 'grpc-stub', version: "${grpcVersion}"
compile group: 'io.grpc', name: 'grpc-services', version: "${grpcVersion}"
compile group: 'io.grpc', name: 'grpc-okhttp', version: "${grpcVersion}"
compile 'com.google.protobuf:protobuf-java:3.5.1'
compile 'com.google.protobuf:protobuf-java-util:3.5.1'
compile group: "io.github.lognet", name: "grpc-spring-boot-starter", version: "3.4.1"
Server is in golang and uses google.golang.org/grpc v1.25.1
Not sure what is causing the issue. Please help. I have seen some posts on github issues regarding this, but that didn't help.