Please answer these questions before submitting your issue.
What did you do? If possible, provide a simple script for reproducing the error.
I run swoole-cli 4.8.13 on windows 10 OS. I use Co\Http\Client to get http result of "http://localhost" but failed with error message: "DNS Lookup resolve failed".
example code:
<?php
use Swoole\Coroutine\Http\Client;
use function Swoole\Coroutine\run;
run(function () {
$client = new Client('localhost', 80);
$client->get('/');
if ($client->errCode) {
echo "error: " . $client->errMsg . "\n";
}
else {
echo $client->body;
}
$client->close();
});
What did you expect to see?
the http result.
What did you see instead?
"error: DNS Lookup resolve failed"
What version of Swoole are you using (show your php --ri swoole)?
swoole-cli 4.8.13 on Windows 10 OS.
It cannot handle DNS resolving if the name is "localhost" or someone defined in C:\Windows\System32\drivers\etc\hosts (similar to /etc/hosts on Linux).
But the code works on Linux and WSL env.
What is your machine environment used (show your uname -a & php -v & gcc -v) ?
uname -a:
MSYS_NT-10.0-19045 lj-laptop 3.3.3-341.x86_64 2022-01-17 11:45 UTC x86_64 Msys
swoole-cli --version
Swoole 4.8.13 (cli) (built: Feb 23 2023 12:05:55) (NTS)
Please answer these questions before submitting your issue.
example code:
What did you expect to see? the http result.
What did you see instead? "error: DNS Lookup resolve failed"
What version of Swoole are you using (show your
php --ri swoole
)? swoole-cli 4.8.13 on Windows 10 OS. It cannot handle DNS resolving if the name is "localhost" or someone defined in C:\Windows\System32\drivers\etc\hosts (similar to /etc/hosts on Linux). But the code works on Linux and WSL env.What is your machine environment used (show your
uname -a
&php -v
&gcc -v
) ? uname -a: MSYS_NT-10.0-19045 lj-laptop 3.3.3-341.x86_64 2022-01-17 11:45 UTC x86_64 Msys swoole-cli --version Swoole 4.8.13 (cli) (built: Feb 23 2023 12:05:55) (NTS)