Comments (8)
@clue thank you sir. i was mislead thinking that close
event needed an argument. it should have dawned on me it didnt need one
from http-client.
HI @hemantjp, I'm not sure I quite follow what your issue is. In case you want to apply a timeout to a pending request, have you seen #104 (comment)?
If your problem persists, can you give a short gist to reproduce the problem you're seeing and/or provide a more detailed exception trace?
from http-client.
@clue , i have already referred to #104 . The close event of the request is not getting the proper arguments. i have passed it an exception class but it is saying none supplied.
attached is almost the complete stacktrace.
could this be an issue because i am using php7?
Should i provide more details?
from http-client.
The close event of the request is not getting the proper arguments. i have passed it an exception class but it is saying none supplied.
The Request
implements WritableStreamInterface
, so its documentation also applies (https://github.com/reactphp/stream#writablestreaminterface): The close
event does not receive any arguments! You should probably use the error
event in this case, which will report an Exception
as per the above documentation.
I hope this helps 👍
I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this 👍
from http-client.
@clue the error
event does not get triggered when i forcibly close the request.
Any suggestion as to how to trigger the promise reject.
i need to handle it down stream on a forcible timeout event.
from http-client.
the error event does not get triggered when i forcibly close the request.
Any suggestion as to how to trigger the promise reject.
Yes, explicitly calling close()
will only emit the close
event, not the error
event. This is expected behavior. What promise are you referring to here? This API does not use promises right now (#41).
from http-client.
@clue Referring to the deferred object i have created to maintain promise like feel.
public function call()
{
$this->request = $this->client->request($this->method, $this->url);
/* this deferred object*/
$deferred = new Deferred();
$this->request->on('response', function (\React\HttpClient\Response $response)use ($deferred) {
$response->on('data', function ($chunk) use ($deferred){
$deferred->resolve($chunk);
});
});
$this->request->on('error', function (\Exception $e) use ($deferred){
$deferred->reject($e->getMessage());
});
Error thrown here
// $this->request->on('close', function (\Exception $e) use ($deferred){
// $deferred->reject($e->getMessage());
// });
$this->request->end();
return $deferred->promise();
}
public function close(){
$this->request->close();
}
from http-client.
Your API seems to suffer from a number of flaws, e.g. it looks like your API is subject to a temporal dependence. If you explicitly call your close()
method, you could as well access your Deferred
to explicitly reject()
it. As an alternative, you may register to the close
event and just reject()
with a generic error there.
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
- 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.