Please answer these questions before submitting your issue. Thanks!
go(function () {
$http = new Co\Http\Client("api.tumblr.com", 80, false);
$ret = $http->get('/v2/blog/peacecorps.tumblr.com/posts/text?api_key=fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4¬es_info=true');
$http->set(['timeout' => 5]);
$http->close();
var_dump(json_decode($http->body, true));
var_dump($http->errCode);
});
parsed json end errCode = 0
What did you see instead?
sometimes it work, sometimes i have 110 error
i mean i run
php test.php
end have 110 error
second time - all ok
What version of Swoole are you using (php --ri swoole)?
swoole support => enabled
Version => 2.1.2
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
openssl => enabled
Linux Native AIO => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
debug => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
alpine 3.6.2
PHP 7.2.4
LibreSSL 2.5.5and where i can found more information about CoHttpClient? This is alies for SwooleCoroutineHttpClient ?
and if i use go(), i must use CoHttpClient? or i can use if want simple client?
110 is UNIX error code, it means timeout, maybe your network is unstable.
You can use socket_strerror($code) to get error message.
Coroutine client must run in the coroutine env, such as goor another event-callbacks.
You can use another client in coroutine (curl), but it would make your server block.
@twose thank you for explaining.
And CoHttpClient is allies for SwooleCoroutineHttpClient ?
I found API documentation, https://wiki.swoole.com/wiki/page/p-coroutine.html
but it's in Chinese, but eng docs doesn't so full(
@lotarbo Yes.
Co is the short name of Coroutine.
All of the short names is here:
| Class | ShortName |
| --------------------- | --------------------------- |
| Co\Server | swoole_server |
| chan | swoole_channel_coro |
| Co\Client | swoole_client_coro |
| swoole_coroutine | swoole_coroutine_util |
| Swoole\Coroutine | swoole_coroutine_util |
| Co | swoole_coroutine_util |
| Co\Http\Client | swoole_http_client_coro |
| Co\Http\Server | swoole_http_server |
| Co\Http\Request | swoole_http_request |
| Co\Http\Response | swoole_http_response |
| Co\Http2\Client | swoole_http2_client_coro |
| Co\Http2\Request | swoole_http2_request_coro |
| Co\MySQL | swoole_mysql_coro |
| Co\MySQL\Statement | swoole_mysql_coro_statement |
| Co\MySQL\Exception | swoole_mysql_coro_exception |
| Co\PostgreSQL | swoole_postgresql_coro |
| Co\Redis | swoole_redis_coro |
| Co\Redis\Server | swoole_redis_server |
| Co\Server\Port | swoole_server_port |
| Co\WebSocket\Server | swoole_websocket_server |
| Co\WebSocket\Frame | swoole_websocket_frame |
All of the aliases is here:
| Class | Alias |
| -------------------------- | ---------------------------- |
| swoole_server | Swoole\Server |
| swoole_timer | Swoole\Timer |
| swoole_event | Swoole\Event |
| swoole_async | Swoole\Async |
| swoole_connection_iterator | Swoole\Connection\Iterator |
| swoole_exception | Swoole\Exception |
| swoole_atomic | Swoole\Atomic |
| swoole_atomic_long | Swoole\Atomic\Long |
| swoole_buffer | Swoole\Buffer |
| swoole_channel | Swoole\Channel |
| swoole_client | Swoole\Client |
| swoole_http_client | Swoole\Http\Client |
| swoole_http_server | Swoole\Http\Server |
| swoole_http_response | Swoole\Http\Response |
| swoole_http_request | Swoole\Http\Request |
| swoole_http2_client | Swoole\Http2\Client |
| swoole_http2_response | Swoole\Http2\Response |
| swoole_lock | Swoole\Lock |
| swoole_mmap | Swoole\Mmap |
| swoole_msgqueue | Swoole\MsgQueue |
| swoole_mysql | Swoole\MySQL |
| swoole_mysql_exception | Swoole\MySQL\Exception |
| swoole_process | Swoole\Process |
| swoole_process_pool | Swoole\Process\Pool |
| swoole_redis | Swoole\Redis |
| swoole_redis_server | Swoole\Redis\Server |
| swoole_ringqueue | Swoole\RingQueue |
| swoole_serialize | Swoole\Serialize |
| swoole_server_port | Swoole\Server\Port |
| swoole_table | Swoole\Table |
| swoole_table_row | Swoole\Table\Row |
| swoole_websocket_server | Swoole\WebSocket\Server |
| swoole_websocket_frame | Swoole\WebSocket\Frame |