Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Guzzle http请求连接失败异常 #35

Closed
sxllllll opened this issue Oct 31, 2024 · 9 comments
Closed

关于Guzzle http请求连接失败异常 #35

sxllllll opened this issue Oct 31, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@sxllllll
Copy link

请求Body字符过长 比如上传一张base64的图片 会导致$connection->stream->write($content); 这里把链接提前close 导致读取不到响应。从而导致 异常提示 Status code must be an integer value between 1xx and 5xx 。 这里会一直tick 直到timeout为止

@cclilshy
Copy link
Member

可以提交一份版本信息吗?
描述中提到的部分关键字是0.7版本后启用的

@sxllllll
Copy link
Author

"cloudtay/ripple-driver": "^1.3"
image

@sxllllll
Copy link
Author

body传入base64图片 会有很大的几率导致请求失败 $socketStream 会提前被close掉 在$connection->stream->onReadable的时候读取不到buffer 就会一直产生 response code 码异常的error

@cclilshy
Copy link
Member

具体场景是 请求完成之前服务端主动断开连接, 从而导致频繁提示
Status code must be an integer value between 1xx and 5xx
对吗? 谢谢反馈,另外有一个小tips:

调用guzzle的终端是否启用了这类配置?如果有,建议对照关闭后的结果

  • export http_proxy=
  • export https_proxy=

@sxllllll
Copy link
Author

sxllllll commented Nov 1, 2024

是的 正常请求,未配置代理
image
参考base64请求编码:
base64-image.txt

@cclilshy
Copy link
Member

cclilshy commented Nov 1, 2024

大致情况了解了,据描述问题发生在: 请求完成之前服务端主动断开连接
期望的结果是发生上述情况时主动抛出异常,而非继续执行错误的处理

据调试得知问题发生于...Client\Connection.php中的tick部分, 可通过补充该部分代码如下可解决问题

Xnip2024-11-01_10-52-45

public function tick(string|false $content): ResponseInterface|null
{
    if ($content === false) {
        if (!$this->headers) {
            throw new RuntimeException('Response header is required');
        } elseif (isset($this->headers['CONTENT-LENGTH'])) {
            throw new RuntimeException('Response content length is required');
        } elseif ($this->chunk) {
            throw new RuntimeException('Response chunked is required');
        } else {
            $this->step = 2;
        }
    }
    // more.....

该问题已被记录并在下次发行时解决,感谢支持💗

@cclilshy cclilshy self-assigned this Nov 1, 2024
@sxllllll
Copy link
Author

sxllllll commented Nov 1, 2024

还有就是body的内容很长的话 很容易导致断开连接,相同Body参数使用Guzzle默认handler 请求没问题,使用Ripple的Client就会出现连接断开的现象

@cclilshy
Copy link
Member

cclilshy commented Nov 1, 2024

收到

@cclilshy cclilshy added the bug Something isn't working label Nov 5, 2024
@cclilshy
Copy link
Member

cclilshy commented Feb 6, 2025

该模块已移至 https://github.com/cloudtay/ripple-http 并得到解决

@cclilshy cclilshy closed this as completed Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants