Found that I cannot connect to local InfluxDB v2 via Laravel Http client:
public function test(): mixed
{
/*
* Works!
* curl --location 'http://localhost:8086/api/v2' \
* --header "Authorization: Token sbjyWZxcUgUMwywJ2X_AIxr4IqdrOViZP1f9INygGzGATW8Chhp1gXxZ_X-dMQAUY4QJLndS02_NeARrU42aWA=="
*/
// Doesn't work!
return Http::
withToken('M1fzBAnjG26mVpdEkIkeq7ztEcA4SDp6w-HfN-sRU-oKnGoFc0Fncg1QzyGt6OQM7o3KMEgeA6fD3AVKgCejIw==')
->post('http://localhost:8086/api/v2');
// Works!
// return response(
// shell_exec(sprintf("curl --location '%s/api/v2/signin' --header \"Authorization: Token %s\"", $this->baseUrl(), $this->getToken()))
// );
}
Guess, uncommented code duplicates curl which is 100% working. But Laravel Http client cannot connect to http://localhost:8086:
Illuminate\Http\Client\ConnectionException: cURL error 7: Failed to connect to localhost port 8086 after 0 ms: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://localhost:8086/api/v2 in file /var/www/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php on line 926
What's wrong - InfluxDB settings or my code with Laravel Http client?