• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

yii – curl命令行请求并不慢,但php curl_exec很慢,怎么回事?

php 搞代码 4年前 (2022-01-25) 27次浏览 已收录 0个评论
文章目录[隐藏]

问题:如题。

<code class="text">curl "http://xxx.com.cn/api/open" --data "access_token=4CC7D18986B8987663E57F3CA0A87198&once=cSTvPM2h9lts&timestamp=1464951645705&sign=2da0302f6aa7b01a5cfa964d818109df&version=1.0&format=JSON&sign_type=MD5&attach=&method=open.jewelStatus.modify&data="%"7B"%"22orderId"%"22"%"3A"%"22413"%"22"%"2C"%"22status"%"22"%"3A100"%"2C"%"22operation"%"22"%"3A2"%"7D" --compressed% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed 100   400    0   118  100   282     77    184  0:00:01  0:00:01   --:--:--   186{"attach":"","errmsg":"","result":"{}","sign":"0ec35efd5c6500baa566937950a9cb40","status":"1000","timestamp":"1465006446020"}</code>
<code>    $url = Yii::$app-><strong style="color:transparent">来2源gaodaima#com搞(代@码&网</strong><label>搞gaodaima代码</label>params['erp_api']['url'];    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, $url);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    // post数据    curl_setopt($ch, CURLOPT_POST, 1);    // post的变量    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);    $output = curl_exec($ch);//**<=Maximum execution time of 30 seconds exceeded**    curl_close($ch);    </code>

但是,诡异的是,我用xdebug跟踪,其实是可以跑通的。。
有没有遇到这个问题的。求解,谢谢!

回复内容:

问题:如题。

<code class="text">curl "http://xxx.com.cn/api/open" --data "access_token=4CC7D18986B8987663E57F3CA0A87198&once=cSTvPM2h9lts&timestamp=1464951645705&sign=2da0302f6aa7b01a5cfa964d818109df&version=1.0&format=JSON&sign_type=MD5&attach=&method=open.jewelStatus.modify&data="%"7B"%"22orderId"%"22"%"3A"%"22413"%"22"%"2C"%"22status"%"22"%"3A100"%"2C"%"22operation"%"22"%"3A2"%"7D" --compressed% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed 100   400    0   118  100   282     77    184  0:00:01  0:00:01   --:--:--   186{"attach":"","errmsg":"","result":"{}","sign":"0ec35efd5c6500baa566937950a9cb40","status":"1000","timestamp":"1465006446020"}</code>
<code>    $url = Yii::$app->params['erp_api']['url'];    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, $url);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    // post数据    curl_setopt($ch, CURLOPT_POST, 1);    // post的变量    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);    $output = curl_exec($ch);//**<=Maximum execution time of 30 seconds exceeded**    curl_close($ch);    </code>

但是,诡异的是,我用xdebug跟踪,其实是可以跑通的。。
有没有遇到这个问题的。求解,谢谢!

问题已找到。
原来是请求的url在php程序环境中是超时了。但xdebug或编辑器也许设了超时时间,所以能够跑通。

  1. 用curl一定要设置超时时间,不然不知道是不是curl超时。

  2. 诡异的问题其实是需要全面地检查来确定问题。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:yii – curl命令行请求并不慢,但php curl_exec很慢,怎么回事?
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址