webman/http-client 出现报错

Chuckle

webman/http-client 出现报错

我的client配置是

    /**
     * 单例复用客户端(进程级,复用长连接)
     * @var Client|null
     */
    protected static ?Client $client = null;

    protected string $host = '';

    public function getClient()
    {
        if (!self::$client) {
            self::$client = new Client([
                'max_conn_per_addr' => 256,
                'keepalive_timeout' => 5,
                'timeout' => 7,
                'connect_timeout' => 2,
            ]);
        }
        return self::$client;
    }
     $this->getClient()->request($fullUrl, [
            'method' => 'GET',
            'version' => '1.1',
            'headers' => ['Content-Type' => 'application/json', 'Connection' => 'keep-alive'],
            'data' => $params,
            'success' => function ($response) use ($fullUrl, $connection, $app, $platform, $path) {}
            }

每次请求是复用的单列

请求三方api,有的时候会出现128错误码,
错误内容:
read xxxxx timeout after 7 seconds
read xxxxx timeout after 12 seconds
read xxxxx timeout after 8 seconds
read xxxxx timeout after 10 seconds

128是对方返回数据超时吗?那为什么超时的时间会有7,8,12,11,10等

172 1 0
1个回答

Mr.Gong

128 是客户端读超时而非服务端返回;超时时间不固定是因为 keepalive 连接复用时的"连接临界失效 + 重建开销 + 事件循环调度延迟"叠加导致的,并非 bug。增大 keepalive_timeout 重试一下

  • 暂无评论
🔝