InfluxDB Client for PHP - Not reporting HTTP 429 status
ph5ive opened this issue · 5 comments
The issue
When using the InfluxDB Client for PHP it doesn't appear to report HTTP 429 status.
Here is an example script WriteAPITest.php
<?PHP
require __DIR__ . '/vendor/autoload.php';
use InfluxDB2\Client;
use InfluxDB2\Model\WritePrecision;;
use InfluxDB2\Point;
$client = new InfluxDB2\Client([
"url" => 'https://██████.cloud2.influxdata.com',
"token" => '████████████████████████████████████████████████',
"bucket" => '██████████',
"org" => '████████',
"precision" => InfluxDB2\Model\WritePrecision::NS,
]);
$writeApi = $client->createWriteApi();
$point = Point::measurement('mem')
->addTag('host', 'host1')
->addField('used_percent', 23.43234543)
->time(microtime(true));
$writeApi->write($point, WritePrecision::S, $bucket, $org);
$client->close();
However, when the API is called using Curl it reports the HTTP 429 status:
- Trying ██████:443...
- Connected to ██████.cloud2.influxdata.com (██████) port 443 (#0)
- ALPN, offering h2
- ALPN, offering http/1.1
- successfully set certificate verify locations:
- CAfile: /etc/ssl/cert.pem
- CApath: none
- (304) (OUT), TLS handshake, Client hello (1):
- (304) (IN), TLS handshake, Server hello (2):
- (304) (IN), TLS handshake, Unknown (8):
- (304) (IN), TLS handshake, Certificate (11):
- (304) (IN), TLS handshake, CERT verify (15):
- (304) (IN), TLS handshake, Finished (20):
- (304) (OUT), TLS handshake, Finished (20):
- SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
- ALPN, server accepted to use h2
- Server certificate:
- subject: CN=██████.cloud2.influxdata.com
- start date: May 15 09:39:45 2022 GMT
- expire date: Aug 13 09:39:44 2022 GMT
- issuer: C=US; O=Let's Encrypt; CN=R3
- SSL certificate verify ok.
- Using HTTP2, server supports multiplexing
- 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 0x14a012a00)
> POST /api/v2/write?org=████████&bucket=██████████&precision=s HTTP/2
> Host: ███████████████████
> user-agent: curl/7.79.1
> accept: _/_
> authorization: Token ████████████████████████████████████████████████
> content-length: 39
> content-type: application/x-www-form-urlencoded
- We are completely uploaded and fine
- Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 429
HTTP/2 429
< date: Thu, 30 Jun 2022 13:35:01 GMT
date: Thu, 30 Jun 2022 13:35:01 GMT
< content-type: application/json; charset=utf-8
content-type: application/json; charset=utf-8
< content-length: 97
content-length: 97
< trace-id: 23d958336e1a58a4
trace-id: 23d958336e1a58a4
< trace-sampled: false
trace-sampled: false
< x-platform-error-code: cardinality limitation
x-platform-error-code: cardinality limitation
< strict-transport-security: max-age=15724800; includeSubDomains
strict-transport-security: max-age=15724800; includeSubDomains
< x-influxdb-request-id: 1a6a995d434485cc61f28512422810d9
x-influxdb-request-id: 1a6a995d434485cc61f28512422810d9
< x-influxdb-build: Cloud
x-influxdb-build: Cloud
<
- Connection #0 to host ██████.cloud2.influxdata.com left intact
{"code":"too many requests","message":"org ███████████ has exceeded plan cardinality limit"}
Steps to reproduce:
- Amend above example script to use the necessary credentials and settings (redacted).
- Run the script, for example:
php WriteAPITest.php
Expected behavior:
I would expect to see the following error the same as the Curl output:
{"code":"too many requests","message":"org ███████████ has exceeded plan cardinality limit"}
Actual behavior:
Nothing is returned.
Specifications:
- Client Version: 2.8.0
- InfluxDB Version: InfluxCloud 2.0
- Platform: Linux
I forgot to include the curl command that created the Curl output above:
curl -iv "https://██████.cloud2.influxdata.com/api/v2/write?org=███████████&bucket=██████████&precision=s" \
--header "Authorization: Token ████████████████████████████████████████████████" \
--data "mem,host=host1 used_percent=23.43234543"
Hi @ph5ive,
thanks for using our client.
The WriteApi
automatically retries writes for error code >= 429
. You can disable retrying by $maxRetries = 0
options:
$writeApi ->writeOptions->maxRetries = 0
Regards
The maxRetries = 0
causes that the error from server is directly throws.