fix(android): registerParty 前等待 channel READY

问题:connect() 是异步的,registerParty() 在 channel 还是 CONNECTING 时就被调用,导致 RST_STREAM 错误

修复:在 registerParty() 开头等待 channel READY 后再发送请求

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-27 04:22:46 -08:00
parent 69de49a000
commit aeb70a6579
1 changed files with 9 additions and 0 deletions

View File

@ -593,6 +593,15 @@ class GrpcClient @Inject constructor() {
partyRole: String = "temporary",
version: String = "1.0.0"
): Result<Boolean> = withContext(Dispatchers.IO) {
// 必须等待 channel READY 后才能注册
Log.d(TAG, "registerParty: Waiting for channel READY...")
val isReady = waitForChannelReady(CONNECTION_TIMEOUT_SECONDS * 1000)
if (!isReady) {
Log.e(TAG, "registerParty: Channel not ready after timeout")
return@withContext Result.failure(Exception("Channel not ready"))
}
Log.d(TAG, "registerParty: Channel is READY, proceeding with registration")
// Save for re-registration
registeredPartyId = partyId
registeredPartyRole = partyRole