Sending multiple async requests without waiting on any responses (HTTP Library) #529
Replies: 1 comment
-
Hey @iSteveZissou thanks for bringing this up 👍 Looking at your code example above, you're currently sending out an HTTP request and waiting for the response before starting to log your messages. In more detail, your code currently sends out a request to the first destination and the In a gist, you're currently only logging once the response comes in, which obviously requires to wait for the response. If you just want to log directly after sending out the HTTP request, you shouldn't try to log inside the I hope I understood your problem right and if our conversation answered your questions or helped you progressing, consider supporting the ReactPHP ecosystem by becoming a sponsor ❤️ |
Beta Was this translation helpful? Give feedback.
-
As per title, I'm using reactphp http library to send multiple requests as the result of an action - in this context to notify other servers of a change (on this server). I don't need to wait for this response - I simply want to send the requests and move on. So ignoring the response altogether. Is there a way I can do this with the promises - perhaps with timeouts?
The code is working well sending the requests but if one of the servers being notified is slow to return the response I'm blocked waiting on that - so again, I'm looking to completely bypass the response.
Still trying to get my head around async and promises.
Code is a bit like this:
I can somewhat solve this by adding
$browser = $browser->withTimeout(1.0);
to set a custom timeout value - this stops the main request being held up waiting on a response but wondering if there's a more elegant solution here?Thanks in advance!
Steve
Beta Was this translation helpful? Give feedback.
All reactions