Yes, your specific issue is definitely a problem, and your solution is good for that. By the way, should your cleanup logic not just go into the CurlHandler destruct, so you don't have to call it each time?
All that being said, my ultimate goal would be to improve the default handler logic to be able to keep precise track of open files, sloce them when they are not necessary, and prevent the number of open files from ever exceeding maxHandles. Then, if the user ever reached the aforementioned server error, all they'd have to do is provide an appropriate maxHandle number that their server can handle.
but, maybe you are right, and I (and others) simply shouldn't send an obscene number of requests to a client. But even in that case, I think implementing the above would be beneficial because there is clearly lots of confusion on this issue. "maxHandles" seems to suggest that no more than maxHandles connections will ever be open at a time. As it is currently implemented, it means that no more than maxHandle CURL handlers will be open at a time, but temp file handles can (and likely do) exceed maxHandle, often by a lot. Maybe there should be a maxFileHandler argument thats totally separate from maxHandle that ensures that I am talking about?
__destruct
, I think I tried that before but the problem was chicken-and-egg; PHP was not invoking the __destruct
because of the curl connection that still wasn't closed. you have to close it first somehow
# Send an asynchronous request.
print_r($options);
$request = new \GuzzleHttp\Psr7\Request($method, $uri,$options);
$promise = $client->sendAsync($request)->then(function ($response) {
echo 'I completed! ' . $response->getBody();
});` I am not getting the right response with the headers but once i remove the headers i get the response back. Is there something i am missing out. You help will be much appreciated .
Hi. I am attempting to use Guzzle to consume this service: https://github.com/orbitdb/orbit-db-http-api.
However, when passing stream = true to the client get method, I receive the error:
<GET https://localhost:3000/db/my-feed/events/load> [CONNECT]
<GET https://localhost:3000/db/my-feed/events/load> [AUTH_RESULT] severity: "2" message: "HTTP/1.0 403 Forbidden
" message_code: "403"
<GET https://localhost:3000/db/my-feed/events/load> [MIME_TYPE_IS] message: "text/plain"
<GET https://localhost:3000/db/my-feed/events/load> [PROGRESS]
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `GET https://localhost:3000/db/my-feed/events/load` resulted in a `403 Forbidden` response in /home/html/orbitdb/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
However, if I remove stream true, it looks fine (debug=true enabled on request):
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3000 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=AU; ST=A; L=B; O=Organization; OU=OrganizationUnit; CN=localhost; emailAddress=demo@example.com
* start date: May 25 14:56:35 2019 GMT
* expire date: Oct 6 14:56:35 2020 GMT
* common name: localhost (matched)
* issuer: C=AU; ST=A; L=B; O=Internet Widgits Pty Ltd; CN=Local Certificate
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x558b8007c8a0)
> GET /db/zdpuAoZQznotzijaUCrgUEQkPVCH64RCmGHPXUnRPX5EQn3L1%2Fmy-feed2/events/replicate.progress HTTP/2
Host: localhost:3000
Accept: text/event-stream
Cache-Control: no-cache
User-Agent: GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.17-0ubuntu0.18.04.1
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200
< content-type: text/event-stream; charset=utf-8
< content-encoding: identity
< cache-control: no-cache
< vary: accept-encoding
< date: Sat, 25 May 2019 15:10:38 GMT
But without stream true I can't access the network stream. I'm using a self signed cert but have generated a local CA cert which I have added to the local CA store. curl and guzzle seem to be able to resolve the cert without problem (I'm not disabling it using flags like curl -k).
(new Client())->post('https://example.com‘);
any idea why we are getting this error after the December updates:
[28-Dec-2019 17:57:20 UTC] PHP Fatal error: Uncaught Error: Call to undefined function GuzzleHttp_idn_uri_convert() in wp-content/plugins/q4vrplugin/vendor/guzzlehttp/guzzle/src/Client.php:220
Stack trace:
#0 guzzlehttp/guzzle/src/Client.php(155): GuzzleHttp\Client->buildUri(Object(GuzzleHttp\Psr7\Uri), Array)
#1 guzzlehttp/guzzle/src/Client.php(183): GuzzleHttp\Client->requestAsync('GET', 'units', Array)
#2 plugin/Models/ApiClient.php(97): GuzzleHttp\Client->request('GET', 'units', Array)
PHP Fatal error: Uncaught Error: Call to undefined method Guzzle\Http\Message\EntityEnclosingRequest::getStatusCode()
$response = $client->post($path, $arr);
$code = $response->getStatusCode();