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

when set 'hook_flags' => SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL, \GuzzleHttp\Client->request() will auto echo response content on the terminal #3800

Closed
bingcool opened this issue Nov 2, 2020 · 2 comments

Comments

@bingcool
Copy link

bingcool commented Nov 2, 2020

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a simple script for reproducing the error.
<?php

include "../vendor/autoload.php";

$http = new swoole_http_server("0.0.0.0", 9509);
$http->set([
    'reactor_num' => 2,
    'worker_num' => 1,
    'max_request' => 100000,
    'task_tmpdir' => '/dev/shm',
    'reload_async' => true,
    'daemonize' => 0,
    'enable_coroutine' => 1,
    'hook_flags' => SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL
]);

$http->on('workerStart', function ($serv, $id) {
    $client = new \GuzzleHttp\Client();
    $url = 'http://www.baidu.com';
    /**
     * when set SWOOLE_HOOK_CURL, \GuzzleHttp\Client->request() will auto echo response content on the terminal.
     */
    $res = $client->request('GET', $url);
});

$http->on('request', function ($request, Swoole\Http\Response $response) use ($http) {
    if($request->server['path_info'] == '/favicon.ico' || $request->server['request_uri'] == '/favicon.ico') {
        $response->end();
        return;
    }

});


$http->start(); 
  1. What did you expect to see?

Dot need auto echo response on the terminal

  1. What did you see instead?

this will uto echo response on the terminal

  1. What version of Swoole are you using (show your php --ri swoole)?

6bcd0d6d19c6:/home/bingcool/wwwroot/workerfy/tests#php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team team@swoole.com
Version => 4.5.5
Built => Oct 31 2020 19:36:01
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
spinlock => enabled
rwlock => enabled
pcre => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?

6bcd0d6d19c6:/home/bingcool/wwwroot/workerfy/tests#uname -a
Linux 6bcd0d6d19c6 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 Linux

6bcd0d6d19c6:/home/bingcool/wwwroot/workerfy/tests#php -v
PHP 7.3.19 (cli) (built: Jun 12 2020 12:27:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.19, Copyright (c) 1999-2018, by Zend Technologies

6bcd0d6d19c6:/home/bingcool/wwwroot/workerfy/tests#gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/9.3.0/lto-wrapper
Target: x86_64-alpine-linux-musl
Configured with: /home/buildozer/aports/main/gcc/src/gcc-9.3.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 9.3.0' --enable-checking=release --disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-default-pie --enable-default-ssp --enable-cloog-backend --enable-languages=c,c++,d,objc,fortran,ada --disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer --enable-shared --enable-threads --enable-tls --with-system-zlib --with-linker-hash-style=gnu
Thread model: posix
gcc version 9.3.0 (Alpine 9.3.0)

@bingcool bingcool changed the title when set 'hook_flags' => SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL, \GuzzleHttp\Client->request() will auto var dump response content on the terminal when set 'hook_flags' => SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL, \GuzzleHttp\Client->request() will auto echo response content on the terminal Nov 2, 2020
@sy-records
Copy link
Member

sy-records commented Nov 2, 2020

  1. As of v4.5.4, SWOOLE_HOOK_ALL includes SWOOLE_HOOK_CURL, So you don't need SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL.
  2. There is a problem with Guzzle, so you need to disable SWOOLE_HOOK_CURL, set SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_CURL, then use a handler that supports coroutine, or use yurunsoft/guzzle-swoole

@sy-records
Copy link
Member

fixed via swoole/library#74 swoole/library#75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants