GetStream.io connection timeout on PHP addActivity

大城市里の小女人 提交于 2019-12-13 00:47:24

问题


I keep getting an error of cURL error 28: Resolving timed out after 35xx milliseconds when certain updates are made to my feeds in GetStream.io (xx = different millisecond values). It seems like this must be coming from an error on GetStream's side that may not be reporting back correctly. Does anyone know if GetStream addActivity calls go over 3.5 seconds?

Since this is intermittent, the only thing I can think is that there may be a GetStream error regarding the foreign_id, as it may potentially be replicating an existing foreign_id. However, there is limited information on GetStream's usage of foreign_id's.

Here is my simplified code for the GetStream call:

//Add Activity to Feeds

    $ccFeeds = ["Event:1", "Game:2", "Character:5", "Region:6"];

    $client = new Client(env('GETSTREAM_API_KEY'), env('GETSTREAM_API_SECRET'));
    $feed = $client->feed('User', 3);

    $sendData = [
        'actor'      => 'User:3',
        'verb'       => 'update',
        'object'     => 'Image:4',
        'target'     => 'Character:5',
        'foreign_id' => 'Image:4',
        'to'         => $ccFeeds
    ];
    $feed->addActivity($sendData);



UPDATED: April 8, 2016 - More info on error
Here is more info on the error we receive:

ConnectException in CurlFactory.php line 186: cURL error 28: Resolving timed out after 3512 milliseconds (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

in CurlFactory.php line 186

at CurlFactory::createRejection(object(EasyHandle), array('errno' => '28', 'error' => 'Resolving timed out after 3512 milliseconds', 'url' => 'https://api.getstream.io/api/v1.0/feed/User/145636936490547870efa96b68a892ca/?api_key= null, 'http_code' => '0', 'header_size' => '0', 'request_size' => '0', 'filetime' => '-1', 'ssl_verify_result' => '0', 'redirect_count' => '0', 'total_time' => '3.512752', 'namelookup_time' => '0', 'connect_time' => '0', 'pretransfer_time' => '0', 'size_upload' => '0', 'size_download' => '0', 'speed_download' => '0', 'speed_upload' => '0', 'download_content_length' => '-1', 'upload_content_length' => '-1', 'starttransfer_time' => '0', 'redirect_time' => '0', 'redirect_url' => '', 'primary_ip' => '', 'certinfo' => array(), 'primary_port' => '0', 'local_ip' => '', 'local_port' => '0')) in CurlFactory.php line 150

at CurlFactory::finishError(object(CurlHandler), object(EasyHandle), object(CurlFactory)) in CurlFactory.php line 103

at CurlFactory::finish(object(CurlHandler), object(EasyHandle), object(CurlFactory)) in CurlHandler.php line 43

at CurlHandler->__invoke(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Proxy.php line 28 at Proxy::GuzzleHttp\Handler{closure}(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Proxy.php line 51

at Proxy::GuzzleHttp\Handler{closure}(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in PrepareBodyMiddleware.php line 72

at PrepareBodyMiddleware->__invoke(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Middleware.php line 30

at Middleware::GuzzleHttp{closure}(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in RedirectMiddleware.php line 68

at RedirectMiddleware->__invoke(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Middleware.php line 59

at Middleware::GuzzleHttp{closure}(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in HandlerStack.php line 67

at HandlerStack->__invoke(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Client.php line 268

at Client->transfer(object(Request), array('synchronous' => true, 'base_uri' => object(Uri), 'timeout' => '3', 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => '5', 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, '_conditional' => array('User-Agent' => 'GuzzleHttp/6.1.1 curl/7.35.0 PHP/5.5.9-1ubuntu4.13'))) in Client.php line 98

at Client->sendAsync(object(Request), array('synchronous' => true)) in Client.php line 104

at Client->send(object(Request)) in Feed.php line 99

at Feed->makeHttpRequest('feed/User/145636936490547870efa96b68a892ca/', 'POST', array('actor' => 'User:145636936490547870efa96b68a892ca', 'verb' => 'update', 'object' => 'Image:1460097866182455b2966b0d6af6c6ca', 'target' => 'UserCharacter:14578366478445749c90d674fcbfcf7a', 'foreign_id' => 'Image:1460097866182455b2966b0d6af6c6ca1460097866', 'to' => array('UserCharacter:14578366478445749c90d674fcbfcf7a xIhp_AjtHawdcoxhOyVkM40-dnk', 'Character:14542764069160f34f6bba72eba8369a 0Z-xTykbo-wxNgPy0NAZts-mDgU', 'Universe:14578366478314e869bd6fdbe67cfb1a FZbzNGVTQhCwa0s7QNu2NbNGZpk', 'Genre:14504636484684adffda0df53e17a83a 07_msjt2sUDptVBstw4gq5ZtPfw')), null, 'feed', 'write') in BaseFeed.php line 152

at BaseFeed->addActivity(array('actor' => 'User:145636936490547870efa96b68a892ca', 'verb' => 'update', 'object' => 'Image:1460097866182455b2966b0d6af6c6ca', 'target' => 'UserCharacter:14578366478445749c90d674fcbfcf7a', 'foreign_id' => 'Image:1460097866182455b2966b0d6af6c6ca1460097866', 'to' => array('UserCharacter:14578366478445749c90d674fcbfcf7a', 'Character:14542764069160f34f6bba72eba8369a', 'Universe:14578366478314e869bd6fdbe67cfb1a', 'Genre:14504636484684adffda0df53e17a83a'))) in ImageSMLHandler.php line 146

at ImageHandler->processImages() in ImagesApiController.php line 55


回答1:


I found that this was actually caused by an issue where Laravel was inconsistently using the \Guzzle\Http\Client instead of GetStream\Stream\Client, even though

use GetStream\Stream\Client;

was defined at the top of the FeedClass I set up. I set the alias in config/app.php to

'Client' => 'GetStream\Stream\Client'

and that seems to have solved the issue.



来源:https://stackoverflow.com/questions/36413620/getstream-io-connection-timeout-on-php-addactivity

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!