We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
该问题出现在本人公司电脑上(家里的电脑正常) 环境:swoole下载网站 : https://www.swoole.com/download 版本swoole-cli-v4.8.13-cygwin-x64.zip 电脑操作系统:windows10 windows cmd窗口运行命令:swoole-cli.exe .\t7.php 问题是: 运行下面代码时
<?php Co\run(function () { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://127.0.0.2"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); var_dump(curl_error($ch)); curl_close($ch); var_dump($result); });
返回: string(26) "Couldn't connect to server" bool(false)
但是以下代码却是正常的
<?php Co\run(function () { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); var_dump(curl_error($ch)); curl_close($ch); var_dump($result); });
返回: string(0) "" string(15) "127.0.0.1Hi!"
他们上面2个的区别是一个是请求127.0.0.1 ,一个是 127.0.0.2 。 那么有当时我觉得可能是 127.0.0.2的问题? 但是我把Co\run(function () {}) 去掉后,结果却正常返回。代码如下:
<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://127.0.0.2"); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); var_dump(curl_error($ch)); curl_close($ch); var_dump($result);
返回值: string(0) "" string(15) "127.0.0.1Hi,Yg!"
所以由此得出是 该电脑 swoole-cli.exe 单纯使用curl正常 但是协程使用curl 无法访问 除了 127.0.0.1 或 localhost 的网站。我应该怎么排查和解决这个问题?
The text was updated successfully, but these errors were encountered:
php -S 127.0.0.2:8080
我用php监听了本地的127.0.0.2:8080是可以访问的
php
你的127.0.0.2是怎么监听的
Sorry, something went wrong.
php -S 127.0.0.2:8080 我用php监听了本地的127.0.0.2:8080是可以访问的 你的127.0.0.2是怎么监听的
我使用的是phpstudy的阿帕奇 监听的,在浏览器上可以正常访问。但是在 Co\run(function () {})外使用curl可以正常访问,在 Co\run(function () {})内curl就是不能访问。 是不是我的公司电脑上装了很多VPN(连接其他公司内网的那种),难道是那些vpn导致的swoole问题?因为我家里的电脑没有安装那些vpn,是可以正常连接的。
下面的输出依然是 127.0.0.1 ,说明关闭协程后请求的是 127.0.0.1,此间的逻辑可能与 swoole 无关,本质上开启 curl-native 之后,协程 curl 和非协程的差异是,协程用的是 curl_multi 相关 API,而非协程用的是 curl_easy 相关 API,但都是交给 libcurl 进行处理,swoole 仅进行事件监听和协程调度,不会改变 HTTP 的任何行为。
curl_multi
curl_easy
HTTP
No branches or pull requests
该问题出现在本人公司电脑上(家里的电脑正常)
环境:swoole下载网站 : https://www.swoole.com/download 版本swoole-cli-v4.8.13-cygwin-x64.zip 电脑操作系统:windows10
windows cmd窗口运行命令:swoole-cli.exe .\t7.php
问题是: 运行下面代码时
返回:
string(26) "Couldn't connect to server"
bool(false)
但是以下代码却是正常的
返回:
string(0) ""
string(15) "127.0.0.1Hi!"
他们上面2个的区别是一个是请求127.0.0.1 ,一个是 127.0.0.2 。 那么有当时我觉得可能是 127.0.0.2的问题? 但是我把Co\run(function () {}) 去掉后,结果却正常返回。代码如下:
返回值:
string(0) ""
string(15) "127.0.0.1Hi,Yg!"
所以由此得出是 该电脑 swoole-cli.exe 单纯使用curl正常 但是协程使用curl 无法访问 除了 127.0.0.1 或 localhost 的网站。我应该怎么排查和解决这个问题?
The text was updated successfully, but these errors were encountered: