grpc:通话已半关闭错误 [英] grpc : call was half-closed error
问题描述
我正在使用Google Cloud Platform Speech API. 我正在使用示例源进行开发. https://github.com/GoogleCloudPlatform/android-docs-样本/树/主/语音/语音
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
几乎与样本来源相同. 除了我的应用中许多VoiceRecorder的启动/停止.
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)
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.
推荐答案
该错误表示您以前调用过onCompleted()
,但现在正在调用onNext()
;那是不允许的.
The error means you previously called onCompleted()
but are now calling onNext()
; that's not allowed.
SpeechService.java
中的代码看起来很可靠,可以避免此类问题.我唯一的猜测是您正在从多个线程使用该类,但是该类不是线程安全的.
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.
这篇关于grpc:通话已半关闭错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!