grpc-java
grpc-java copied to clipboard
io.grpc.StatusRuntimeException: INTERNAL: No value received for unary call
io.grpc.StatusRuntimeException: INTERNAL: No value received for unary call I'm getting this Exception message from my grpc unary call while running my signed apk . I get this RunTime Exception Only when I Get a Release Version and not on debug mode please help me out I'm really getting frustrated:
here is my build.gradle (module):
apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
//TODO KOTLIN
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 97
versionName "2.2.6.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
sourceSets {
main {
proto {
srcDir 'src/main/protos'
}
}
}
}
buildTypes {
debug {
// useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
lintOptions {
abortOnError false
disable 'MissingTranslation'
}
}
}
dataBinding {
//noinspection DataBindingWithoutKapt
enabled = true;
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
protobuf {
protoc { artifact = 'com.google.protobuf:protoc:4.0.0-rc-2' }
plugins {
grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.43.1'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
java { option 'lite' }
}
task.plugins {
grpc {
option 'lite'
}
}
}
}
}
dependencies {
// ramotion , animation open cell
implementation 'com.ramotion.foldingcell:folding-cell:1.2.3'
// time piker persian
implementation 'com.mohamadamin:persianmaterialdatetimepicker:1.2.1'
// shine button animation
implementation 'com.sackcentury:shinebutton:1.0.0'
// navigation tab bar
implementation 'devlight.io:navigationtabbar:1.2.5'
// swipe layout
implementation 'com.daimajia.swipelayout:library:1.2.0'
// fab
implementation 'com.github.clans:fab:1.6.4'
// search bar
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
// guid for app
implementation 'uk.co.samuelwall:material-tap-target-prompt:2.14.0'
// chart
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
// Sliding Up Panel
implementation 'com.sothree.slidinguppanel:library:3.4.0'
// barcode scanner
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
// lib in app
implementation(name: 'RootTools', ext: 'aar')
implementation(name: 'RootShell', ext: 'aar')
implementation files('libs/achartengine-1.2.0.jar')
implementation files('libs/bixolon_printer_V132.jar')
implementation files('libs/jpos121-controls.jar')
implementation files('libs/xerces.jar')
implementation files('libs/urovo_sdk_v2.3.706.jar')
implementation 'androidx.ads:ads-identifier:1.0.0-alpha04'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//problem in permissions
implementation 'androidx.preference:preference:1.1.1'
//Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//Glide
implementation("com.github.bumptech.glide:glide:4.9.0") {
exclude group: 'androidx.vectordrawable', module: 'vectordrawable-animated'
}
//rxjava2_retrofit
implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0"
//rxjava_rxandroid
implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
//rxLifeCycle
implementation 'com.uber.autodispose:autodispose:1.1.0'
implementation 'com.uber.autodispose:autodispose-android-archcomponents:1.1.0'
implementation 'com.github.afshin1394:central_exception_handler:1.0.5'
//Grpc
implementation 'io.grpc:grpc-okhttp:1.43.1'
implementation 'io.grpc:grpc-protobuf-lite:1.43.1'
implementation 'io.grpc:grpc-stub:1.43.1'
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+
}
and my build.gradle(project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17'
// classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
here is one of my protobuf files:
syntax = "proto3";
option java_package = "com.saphamrah";
option java_outer_classname = "AccountTypeProto";
package Amargar;
service AccountType{
rpc GetAccountType(AccountTypeRequest) returns(AccountTypeReplyList);
}
message AccountTypeRequest{
}
message AccountTypeReply{
int32 AccountTypeID = 1;
string AccountTypeName = 2;
}
message AccountTypeReplyList{
repeated AccountTypeReply AccountTypeReplys = 1;
}
and this is how I create my unary calls:
{
try {
ServerIpModel serverIpModel = new PubFunc().new NetworkUtils().getServerFromShared(context);
serverIpModel.setPort("5000");
if (serverIpModel.getServerIp().trim().equals("") || serverIpModel.getPort().trim().equals("")) {
String message = "can't find server";
PubFunc.Logger logger = new PubFunc().new Logger();
logger.insertLogToDB(context, Constants.LOG_EXCEPTION(), message, NoeHesabDAO.class.getSimpleName(), activityNameForLog, "fetchNoeHesabGrpc", "");
retrofitResponse.onFailed(Constants.HTTP_EXCEPTION(), message);
} else {
CompositeDisposable compositeDisposable = new CompositeDisposable();
ManagedChannel managedChannel = GrpcChannel.channel(serverIpModel);
AccountTypeGrpc.AccountTypeBlockingStub accountTypeBlockingStub = AccountTypeGrpc.newBlockingStub(managedChannel);
AccountTypeProto.AccountTypeRequest accountTypeRequest = AccountTypeProto.AccountTypeRequest.newBuilder().build();
Callable<AccountTypeProto.AccountTypeReplyList> accountTypeReplyListCallable = () -> accountTypeBlockingStub.getAccountType(accountTypeRequest);
RxAsync.makeObservable(accountTypeReplyListCallable)
.map(accountTypeReplyList -> {
ArrayList<NoeHesabModel> models = new ArrayList<>();
for (AccountTypeProto.AccountTypeReply reply : accountTypeReplyList.getAccountTypeReplysList()) {
NoeHesabModel model = new NoeHesabModel();
model.setCcNoeHesab(reply.getAccountTypeID());
model.setNameNoeHesab(reply.getAccountTypeName());
}
return models;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<ArrayList<NoeHesabModel>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
compositeDisposable.add(d);
}
@Override
public void onNext(@NonNull ArrayList<NoeHesabModel> noeHesabModels) {
response.onSuccess(noeHesabModels);
}
@Override
public void onError(@NonNull Throwable e) {
response.onFailed(Constants.HTTP_EXCEPTION(), e.getMessage());
}
@Override
public void onComplete() {
if (!compositeDisposable.isDisposed()) {
compositeDisposable.dispose();
}
compositeDisposable.clear();
}
});
}
}catch (Exception exception){
PubFunc.Logger logger = new PubFunc().new Logger();
logger.insertLogToDB(context, Constants.LOG_EXCEPTION(), exception.getMessage(), NoeHesabDAO.class.getSimpleName(), activityNameForLog, "fetchNoeHesabGrpc", "");
retrofitResponse.onFailed(Constants.HTTP_EXCEPTION(), exception.getMessage());
}
}
thanks for your help
It looks like the client didn't receive a response message but just an OK status code. Can you confirm the server is sending a response?
It looks like the client didn't receive a response message but just an OK status code. Can you confirm the server is sending a response?
Yes the server is working properly. For testing the server I'm using bloomRpc and it's returning the response and even I'm getting the response in my android app on debug version. But when I get the signed release version of my app it's giving me this runtime exception.its really annoying .I've written the server side of grpc with dotnet5 and I can't see any problem.
... I'm getting the response in my android app on debug version. But when I get the signed release version of my app it's giving me this runtime exception.its really annoying .
That's strange. Is it possible to collect logs and stack trace on the client side?
2022-01-05 10:44:57.634 3740-3740/? I/Layer: id=773[1] Destroyed c2541ca com.saphamrah/com.saphamrah.MVP.splash.SplashActivity#0
2022-01-05 10:44:57.635 3740-5269/? I/Layer: id=783 removeFromCurrentState Dim Layer for - Task=169#0 (73)
2022-01-05 10:44:57.635 3740-5269/? I/Layer: id=794 removeFromCurrentState Surface(name=Dim Layer for - Task=169)/@0x9a53234 - animation-leash#0 (73)
2022-01-05 10:44:57.636 3740-5269/? I/SurfaceFlinger: id=783 Removed Dim Layer for - Task=169#0 (73)
2022-01-05 10:44:57.636 3740-5269/? I/SurfaceFlinger: id=794 Removed Surface(name=Dim Layer for - Task=169)/@0x9a53234 - animation-leash#0 (73)
2022-01-05 10:44:57.637 3740-3740/? I/Layer: id=778[1] Destroyed com.saphamrah/com.saphamrah.MVP.splash.SplashActivity$_23077#0
2022-01-05 10:44:57.640 3740-3740/? D/SurfaceFlinger: Display 0 HWC layers:
DEVICE | 0x76d4a15c00 | 0002 | RGBA_8888 | 0.0 0.0 1200.0 1920.0 | 0 0 1200 1920 | com.saphamrah/com.saphamrah.MVP.splash.SplashActivity$_23077#1
DEVICE | 0x76d4a14a80 | 0000 | RGBA_8888 | 0.0 0.0 1200.0 48.0 | 0 0 1200 48 | StatusBar$_4397#0
DEVICE | 0x76d4a13540 | 0000 | RGBA_8888 | 0.0 0.0 67.0 293.0 | 1133 406 1200 699 | com.samsung.android.app.cocktailbars[...]arservice.CocktailBarService$_6867#0
DEVICE | 0x76d4a14080 | 0000 | RGBA_8888 | 0.0 0.0 1200.0 96.0 | 0 1824 1200 1920 | NavigationBar0$_4397#0
2022-01-05 10:44:57.642 3654-3711/? E/Netd: getNetworkForDns: getNetId from enterpriseCtrl is netid 0
2022-01-05 10:44:57.643 23077-23535/? I/Grpc: --> [REQUEST] Global.LoginInfo/GetLoginInfo:
# com.saphamrah.LoginInfoProto$LoginInfoRequest@7bc6f
2022-01-05 10:44:57.644 4077-4119/? D/SensorManager: TYPE_LIGHT (5): 68.000000
2022-01-05 10:44:57.650 3740-3740/? I/Layer: id=794[1] Destroyed Surface(name=Dim Layer for - Task=169)/@0x9a53234 - animation-leash#0
2022-01-05 10:44:57.651 3740-3740/? I/Layer: id=783[1] Destroyed Dim Layer for - Task=169#0
2022-01-05 10:44:57.795 23077-23535/? I/Grpc: <-- [STATUS] OK[DESCRIPTION]null
2022-01-05 10:44:57.796 23077-23535/? W/System.err: io.grpc.StatusRuntimeException: INTERNAL: No value received for unary call
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at com.saphamrah.LoginInfoGrpc$LoginInfoBlockingStub.getLoginInfo(LoginInfoGrpc.java:177)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at com.saphamrah.PubFunc.PubFunc$LoginInfo.lambda$callLoginInfoService$0(PubFunc.java:795)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at com.saphamrah.PubFunc.PubFunc$LoginInfo$$ExternalSyntheticLambda1.call(Unknown Source:4)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at com.saphamrah.Utils.RxUtils.RxAsync$1.subscribeActual(RxAsync.java:46)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.reactivex.Observable.subscribe(Observable.java:12090)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.reactivex.Observable.subscribe(Observable.java:12090)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2022-01-05 10:44:57.797 23077-23535/? W/System.err: at java.lang.Thread.run(Thread.java:923)
2022-01-05 10:44:57.797 23077-23535/? E/RxAsync: Error transaction from the database
this is the stack trace that is related to the grpc call.
Thank you. Just to summarize/confirm:
- you have a gRPC server written in C#/dotnet5 that is used in all of your tests
- you have been able to make successful unary calls from bloomRpc to this server
- you have been able to make successful unary calls from your Android debug client app
- but the Android release version client app is not able to make the same unary call and it is consistently failing with "No value received for unary call"
We briefly discussed it internally (CC @ejona86 @dapengzhang0). It's possible that this is a timing issue combined with some quirks of the dotnet server. Would it be possible to get Wireshark traces for the error case?
I'm having the same issue did you find any solution for it @sanjaypujare , @ejona86 , @dapengzhang0 , @afshin1394
@pouriaHemmati, are you seeing it when communicating with a C# server as well? Can you provide the additional debug data we had requested in https://github.com/grpc/grpc-java/issues/8797#issuecomment-1005907432 ?
@ejona86 There is no problem with the connection to the server and it works in the debug mode of the application , I'm a freelancer and I do not have access to server information , But I have a problem with the client version of the Android release version
protoc { artifact = 'com.google.protobuf:protoc:4.0.0-rc-2' } plugins { grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.43.1' } }
@afshin1394 Why are you using protoc 4.0.0-rc-2 with protoc-gen-grpc-java:1.43.1? The major version of protoc 4 seems too high, and it is not tested/compatible with protoc-gen-grpc-java:1.43.1. Can you test with protoc:3.19.2 that is officially supported by protoc-gen-grpc-java:1.43.1?
@dapengzhang0 thanks. I change the version of protoc:4.0.0-rc-2 to 1.43.1 but still the issue persists :(
@afshin1394 is this still happening? It will be good to have a reproducible test case/env so we can reproduce it here
@dapengzhang0 Yes it is. Does this issue have any relation to ssl certificate? we are working in our local network and there is no ssl set on the rpc endpoint.
@dapengzhang0 Yes it is. Does this issue have any relation to ssl certificate? we are working in our local network and there is no ssl set on the rpc endpoint.
Is it possible that in your debug case there is no SSL is being used and in the release use case it is using SSL and that might be the reason for difference in behavior?
I wonder if this is related to #8866. One is client-side and one is server-side, but the code I was poking through for it is mostly used by both sides (although the results it produces are quite different). Once we confirm our understanding of #8866, we should probably check whether something similar is possible here. We may get lucky and have one bug fix for both.
Is this still an issue? #8866 was resolved with a server-only fix and I didn't see an obvious situation the same thing would happen on client-side. Since few users are impacted, I wonder if this is a C# server problem (maybe already fixed).
I'm closing this in the hope it was a C# problem and has been fixed. If one of the earlier posters here is still seeing it, comment, and we can reopen.
If someone else is seeing this, make a new issue and link to this issue. It is very possibly a different issue that just has the same error.