hyperf / hyperf/grpc-client

客户端流导致的channel复用没有初始话

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
4
Forks
6
PR merge metrics
No merged PRs in 30d

Description

对于一个客户端流来说 服务端调用了SendAndClose

![Image](https://github.com/user-attachments/assets/7241cf22-c527-4e39-b955-017f42b8c048)

客户端函数runReceiveCoroutine 对这个流进行revc 实际上进行了3次
第一次是正常的数据返回 但是客户端流只允许调用一次recv 就不会触发到GrpcClientrecv中的 if (($response === false && $channel->errCode === SWOOLE_CHANNEL_TIMEOUT) || ($response instanceof Response && ! $response->pipeline)) {

![Image](https://github.com/user-attachments/assets/350176a2-5edd-4e09-916e-5662e89912af)

第二次是关闭

第三次response 为false 走到了如下流程:

![Image](https://github.com/user-attachments/assets/6f9bbdc5-2ec6-4d24-b2a9-616430c480b7)

closeRecv函数在进行channel 回收的时候没有判断channel里面是否有数据 直接进行了回收

下一个请求获取从channel池里面获取channel 获取到旧的channel 此时channel里面的数据 是第一次请求获取响应中的第二个响应及关闭响应 导致GrpcClient.php中recv进行读取的时候 读到的数据是关闭请求 之后才会触发重置和回收channal

![Image](https://github.com/user-attachments/assets/38b74e55-c93b-47b3-b990-1ddb6036c9e6)
我尝试进行多读一次 和 在closeRecv进行channel->pop() 是可以解决这个问题

![Image](https://github.com/user-attachments/assets/b3ab625c-4d3b-464c-8f40-cefe59c0a047)

![Image](https://github.com/user-attachments/assets/6da3581d-1546-47a9-a5ea-90cd18ee99ac)

不知道是不是我的使用方式有什么问题?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.