grpc : call was half-closed error

只愿长相守 提交于 2020-12-12 10:25:12

问题


I'm using Google Cloud Platform Speech API. I'm developing using sample source. https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech

almost the same as sample source. except many start/stop of VoiceRecorder in my app.

I got this error in samsung devices. I didn't get this error in huawei devices.

com.google.common.base.Preconditions.checkState (Preconditions.java:444) io.grpc.internal.ClientCallImpl.sendMessage (ClientCallImpl.java:389) io.grpc.ForwardingClientCall.sendMessage (ForwardingClientCall.java:67) io.grpc.stub.ClientCalls$CallToStreamObserverAdapter.onNext (ClientCalls.java:302) com.example.myapp.SpeechService.recognize (SpeechService.java:299) com.example.myapp.MyActivity$1.onVoice (MyActivity.java:152) com.example.myapp.VoiceRecorder$ProcessVoice.run (VoiceRecorder.java:224)

Please help me if you have experienced the same problem. Thanks in advance.


回答1:


The error means you previously called onCompleted() but are now calling onNext(); that's not allowed.

The code in SpeechService.java looks pretty reliable to avoid this sort of problem. My only guess is that you're using the class from multiple threads, but the class is not thread-safe.



来源:https://stackoverflow.com/questions/51358715/grpc-call-was-half-closed-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!