Comments (4)
Hey thank you for reporting your issue. By the looks of it you're calling $promise->wait();
which forces the promise to resolve and blocks the loop. Running the loop the normal way, $loop->run();
will ensure the loop isn't blocked. I've just tried your URL with this example and had no issues what so ever: https://github.com/WyriHaximus/react-guzzle-psr7/blob/master/examples/basic.php
This should resolve your issue, so I'll close this for now. If you feel this problem persists, please report back and we can reopen this 👍
from http-client.
With other url's my code is not blocking.
When I change my code to
<?php
require_once __DIR__ . '/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$handler = new WyriHaximus\React\GuzzlePsr7\HttpClientAdapter($loop);
$client = new GuzzleHttp\Client([
'handler' => GuzzleHttp\HandlerStack::create($handler),
]);
$request = new GuzzleHttp\Psr7\Request('GET', 'https://wizzair.com/');
$promise = $client->sendAsync($request)->then(function (Psr\Http\Message\ResponseInterface $response) {
echo (string)$response->getBody();
}, function (Exception $e) {
echo $e;
});
$loop->run();
I get
Exception: Unable to validate "27C" as chunk length header in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php:122
Stack trace:
#0 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(70): React\HttpClient\ChunkedStreamDecoder->iterateBuffer()
#1 [internal function]: React\HttpClient\ChunkedStreamDecoder->handleData('="Original" src...', Object(React\Stream\Stream))
#2 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#3 /home/mateusz/git/react-guzzle-test/vendor/react/stream/src/Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#4 [internal function]: React\Stream\Stream->handleData(Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#5 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#6 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#7 /home/mateusz/git/react-guzzle-test/test.php(18): React\EventLoop\StreamSelectLoop->run()
#8 {main}
Next RuntimeException: An error occurred in the underlying stream in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/Response.php:90
Stack trace:
#0 [internal function]: React\HttpClient\Response->handleError(Object(Exception))
#1 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#2 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(122): React\HttpClient\ChunkedStreamDecoder->emit('error', Array)
#3 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(70): React\HttpClient\ChunkedStreamDecoder->iterateBuffer()
#4 [internal function]: React\HttpClient\ChunkedStreamDecoder->handleData('="Original" src...', Object(React\Stream\Stream))
#5 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#6 /home/mateusz/git/react-guzzle-test/vendor/react/stream/src/Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#7 [internal function]: React\Stream\Stream->handleData(Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#8 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#9 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#10 /home/mateusz/git/react-guzzle-test/test.php(18): React\EventLoop\StreamSelectLoop->run()
#11 {main}
Next RuntimeException: An error occured in the response in /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/Request.php:150
Stack trace:
#0 [internal function]: React\HttpClient\Request->React\HttpClient\{closure}(Object(RuntimeException), Object(React\HttpClient\Response))
#1 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Object(Closure), Array)
#2 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/Response.php(94): React\HttpClient\Response->emit('error', Array)
#3 [internal function]: React\HttpClient\Response->handleError(Object(Exception))
#4 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#5 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(122): React\HttpClient\ChunkedStreamDecoder->emit('error', Array)
#6 /home/mateusz/git/react-guzzle-test/vendor/react/http-client/src/ChunkedStreamDecoder.php(70): React\HttpClient\ChunkedStreamDecoder->iterateBuffer()
#7 [internal function]: React\HttpClient\ChunkedStreamDecoder->handleData('="Original" src...', Object(React\Stream\Stream))
#8 /home/mateusz/git/react-guzzle-test/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#9 /home/mateusz/git/react-guzzle-test/vendor/react/stream/src/Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#10 [internal function]: React\Stream\Stream->handleData(Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#11 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #96, Object(React\EventLoop\StreamSelectLoop))
#12 /home/mateusz/git/react-guzzle-test/vendor/react/event-loop/src/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#13 /home/mateusz/git/react-guzzle-test/test.php(18): React\EventLoop\StreamSelectLoop->run()
Other url's works, just wizzair is somehow special.
from http-client.
Your example works fine until I change url to https://wizzair.com/ . Then i get An error occured in the response
.
from http-client.
I fix that #77
from http-client.
Related Issues (20)
- Time Out Question HOT 1
- question regarding writing HOT 2
- Hanging connector HOT 1
- Unable to validate "1 " as chunk length header HOT 3
- strtolower() expects parameter 1 to be string, array given HOT 1
- Delay Request Connection HOT 6
- Error on "close" event HOT 8
- How to get the full response body? HOT 1
- [bug]Concurrent with more than 1000 requests. HOT 4
- client pool HOT 1
- Memory leak in SecureConnector HOT 4
- Integrate Server Sent event api (EventSource) or streaming HTTP api HOT 1
- Support detecting response body boundaries HOT 1
- Can this library be used in php-fpm mode? HOT 2
- Trying to POST multipart/form-data HOT 2
- Support for certificate authentication when using HttpClientAdapter HOT 1
- Stop streaming half-way. HOT 1
- Support HTTP upgrades (WebSocket etc.) HOT 1
- is $loop->run(); blocking? HOT 4
- Heads up! Development focus on react/http
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-client.