php Connection timed out after 30000 milliseconds

function HttpRequest($url, $params, $method = 'GET', $header = array(), $bEncode = true)
{
$opts = array(
CURLOPT_TIMEOUT => ,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HTTPHEADER => $header
);
/* 根据请求类型设置特定参数 */
switch (strtoupper($method)) {
case 'GET':
$opts[CURLOPT_URL] = $url;
break;
case 'POST':
$opts[CURLOPT_URL] = $url;
$opts[CURLOPT_POST] = 1;
$opts[CURLOPT_POSTFIELDS] = json_encode($params, JSON_UNESCAPED_UNICODE);
break;
default:
throw new Exception('不支持的请求方式!');
}
/* 初始化并执行curl请求 */
$ch = curl_init();
curl_setopt_array($ch, $opts);
$data = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
echo $error;
if ($error) throw new Exception('请求发生错误:' . $error);
return $data;
}
如果某个请求url出现这种问题
只能排除法看出问题
1. 使用你的curl http代码请求别的网站试试
2. 相同的代码在别的电脑上,别的服务器上试试
3. ping 一下你请求的url的host, 多ping ping 基本素养别忘。 试了三个小时最后发现是个原因,根本ping不通
php Connection timed out after 30000 milliseconds的更多相关文章
- Action.c(28): Error -27796: Failed to connect to server "xxxx": [10060] Connection timed out
Error -27796: Failed to connect to server "125.93.51.230:8080": [10061] Connection refused ...
- weedfs getsockopt: connection timed out
启动master weed master -ip 10.191.197.133 -mdir /namenode -ip.bind 10.191.197.133 I0809 16:53:51 7721 ...
- ssh启动报错:org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
ssh项目启动报错: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection t ...
- rabbitMQ Connection timed out
在VM中部署了一个rabbitMQ server ,在物理机上按照rabbitMQ官网上的 java的教程访问VM中的rabbitMQ报如下错误: Exception in thread " ...
- nginx 报错 upstream timed out (110: Connection timed out)解决方案
nginx 作PHP的web接口服务器. 在线上发现时不时经常崩溃.504,导致接口访问无响应回复. 查看日志: [error] 11618#0: *324911 upstream timed out ...
- 压测 502 日志报错 upstream timed out (110: Connection timed out)
环境介绍 服务器:centos6.5服务:nginx proxy 问题描述: 压测 开发同事 的开发环境项目没事,但是 线上机器 命中%50 ,大量502 php的某些页面打不开,页面提示gatewa ...
- hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:
hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception: 所报异常: 严重 ...
- nginx 报错 upstream timed out (110: Connection timed out)解决方案【转】
转自 nginx 报错 upstream timed out (110: Connection timed out)解决方案 - 为程序员服务http://outofmemory.cn/code-sn ...
- 项目的ip地址更改,用git从远程提取代码出现错误,提示为 network error connection timed out
昨天公司的ip进行了修改,在今天从远程提取代码的过程中提示network error connection timed out错误,从网上看了一下解决方法 1:打开项目文件夹,点击查看 2:勾选隐藏的 ...
随机推荐
- 【问题解决方案】Markdown正文中慎用星号否则容易变斜体
参考链接: [学习总结]Markdown 使用的正确姿势:第九部分-斜体and加粗 原理: 注意: Markdown中,若在正文中使用星号,如乘号或者指针的星号时,需要特别注意 当一句话中包含两个或者 ...
- 【学习总结】Python-3-round()函数的奇进偶弃的问题
参考: 本教程的评论区:菜鸟教程-Python3-Python数字 "4舍6入5看齐,奇进偶不进" 取代"四舍五入". round()函数: 可以在第二个参数指 ...
- XMPP即时通讯协议使用(七)——利用Strophe实现WebIM及strophe.plugins插件使用
Strophe简介与Openfire配置 Strophe.js是为XMPP写的一个js类库.因为http协议本身不能实现持久连接,所以strophe利用BOSH模拟实现持久连接. 官方文档: http ...
- presentingViewController、presentedViewController区别
解释两个属性:presentingViewController 和 presentedViewController A----(present)-----B----(present)-----C 1. ...
- 源码分析--HashSet(JDK1.8)
HashSet为无序不可重复集合.底层几乎全部借助HashMap实现,比较简单.本篇简要分析一下HashSet源码. 首先是成员变量: 1.真正保存数据的HashMap实例 private trans ...
- 接口需要上一个接口的返回值(unittest)
import unittest,requests ''' 使用unittest框架的时候,这个接口需要上一个接口的返回值 ''' class Test_case(unittest.TestCase): ...
- The main Method
The main Method You can call static methods without having any objects. For example, you never const ...
- NET Core+win10+Jenkins+Github持续集成
本篇和上一篇NET Core+win10+Jenkins+Gogs+open ssh持续集成没什么区别,只不过源码库换成github. 这里有两点不一样的是: 获取的代码的凭证不用用户名和密码用sec ...
- Android 获取手机(ios,android)的设备唯一码(mac地址, IMEI)
{ /*获取手机(ios,android)的设备唯一码(mac地址, IMEI)2018年02月16日 ⁄ 综合 ⁄ 共 2697字 ⁄ 字号 小 中 大 ⁄ 评论关闭 app中总会用到客户端下载量数 ...
- boost algorithm
BOost Algorithm provides algorithms that complement the algorithms from the standard library. Unlike ...