国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

webman2.1+swoole6+php8.1上傳文件報(bào)錯(cuò)

renloong

問題描述

使用寶塔面板安裝的php swoole6擴(kuò)展,在自定義進(jìn)程中使用協(xié)程,在協(xié)程中使用定時(shí)任務(wù)創(chuàng)建協(xié)程,在協(xié)程中使用GuzzleHttp上傳文件報(bào)錯(cuò)

程序代碼

class VideoDownload1
{
    public function onWorkerStart()
    {
        new Crontab('*/2 * * * * *', function () {
            Coroutine::create(function(){
                try {
                    $url = '';
                    $file=fopen($filePath, 'r');
                    if(!$file){
                        throw new \Exception('file not found');
                    }
                    $multipart = [
                        [
                            'name' => 'file',
                            'contents' => $file,
                        ],
                        [
                            'name' => 'user_id',
                            'contents' => '1',
                        ]
                    ];
                    $client = new Client();
                    $client = $client->request('POST', $url, [
                        'headers' => [
                            'Token' => '',
                            'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36',
                        ],
                        'multipart' => $multipart,
                        'timeout' => 3000,
                    ]);
                    $response = $client->getBody()->getContents();
                    $data = json_decode($response, true);
                    if ($data['status'] == 'Success') {
                    }
                } catch (ClientException $th) {
                    throw new \Exception($th->getMessage(),$th->getCode());
                }
            });
        });
    }
}

報(bào)錯(cuò)信息

cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

截圖報(bào)錯(cuò)信息里報(bào)錯(cuò)文件相關(guān)代碼

return [
    'VideoDownload'  => [
        'eventLoop' => Swoole::class,
        'handler'  => VideoDownload1::class,
        'count'=>1
    ]
];

操作系統(tǒng)及workerman/webman等框架組件具體版本

框架:Workerman/5.1.0 Webman/2.1
PHP:PHP/8.1.31 (Jit off)
Swoole:通過寶塔php擴(kuò)展安裝的swoole6
系統(tǒng):CentOS 7.6.1810 x86_64
寶塔:9.4.0

434 3 1
3個(gè)回答

renloong

使用curl訪問baidu返回的結(jié)果是:“string(161) "<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>bfe/1.0.8.18</center>
</body>
</html>
"”

class VideoDownload1
{
    public function onWorkerStart()
    {
        new Crontab('*/2 * * * * *', function () {
            Coroutine::create(function(){
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, 'https://baidu.com');
                curl_setopt($ch, CURLOPT_HEADER, false);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $result = curl_exec($ch);
                var_dump(curl_error($ch));
                curl_close($ch);
                var_dump($result);
            });
        });
    }
}
  • 暫無評(píng)論
輕云蔽月

php --ri swoole 看看有沒有curl-native,沒有的話編譯swoole的時(shí)候加個(gè)--enable-swoole-curl

renloong

已解決

問題的原因是CentOS7安裝了swoole6的原因,在寶塔的安裝腳本中判斷了curl的版本,只有高于7560才會(huì)安裝curl,CentOS7最高支持的curl版本是7290

if [ "${curl_version}" -gt '7560' ];then
    ./configure --with-php-config=/www/server/php/$version/bin/php-config --enable-openssl --enable-sockets --enable-swoole-curl 
else
    ./configure --with-php-config=/www/server/php/$version/bin/php-config --enable-openssl --enable-sockets
  • 暫無評(píng)論
??