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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. rabbitMQ Connection timed out

    在VM中部署了一个rabbitMQ server ,在物理机上按照rabbitMQ官网上的 java的教程访问VM中的rabbitMQ报如下错误: Exception in thread " ...

  5. nginx 报错 upstream timed out (110: Connection timed out)解决方案

    nginx 作PHP的web接口服务器. 在线上发现时不时经常崩溃.504,导致接口访问无响应回复. 查看日志: [error] 11618#0: *324911 upstream timed out ...

  6. 压测 502 日志报错 upstream timed out (110: Connection timed out)

    环境介绍 服务器:centos6.5服务:nginx proxy 问题描述: 压测 开发同事 的开发环境项目没事,但是 线上机器 命中%50 ,大量502 php的某些页面打不开,页面提示gatewa ...

  7. hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:

    hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:   所报异常: 严重 ...

  8. nginx 报错 upstream timed out (110: Connection timed out)解决方案【转】

    转自 nginx 报错 upstream timed out (110: Connection timed out)解决方案 - 为程序员服务http://outofmemory.cn/code-sn ...

  9. 项目的ip地址更改,用git从远程提取代码出现错误,提示为 network error connection timed out

    昨天公司的ip进行了修改,在今天从远程提取代码的过程中提示network error connection timed out错误,从网上看了一下解决方法 1:打开项目文件夹,点击查看 2:勾选隐藏的 ...

随机推荐

  1. Vue-cli3 环境的搭建

    Vue-cli3 环境的搭建 准备 浏览器插件:Vue.js devtools VsCode 和 VsCode 插件 WebStorm Nodejs vue-cli git 起飞 安装vue-cli3 ...

  2. 一、RabbitMQ安装与测试连接

    一.下载NuGet支持的RabbitMQ.Client客户端库与安装RabbitMQ服务. 1.安装客户端库操作服务. 2.安装服务. 步骤一.下载Erlang. 步骤二.下载RabbitMQ服务 采 ...

  3. swagger集成到springBoot 项目中

    1 pom 文件加包依赖 <dependency> <groupId>io.springfox</groupId> <artifactId>spring ...

  4. Vue:对象更改检测注意事项

    还是由于 JavaScript 的限制,Vue 不能检测对象属性的添加或删除: var vm = new Vue({ data: { a: 1 } }) // `vm.a` 现在是响应式的 vm.b ...

  5. 手写9x9乘法表,冒泡排序

    手写9x9乘法表,冒泡排序 9x9乘法表 class Demo {public static void main(String[] args) {for(int x = 0;x <= 9; x+ ...

  6. bzoj1190 [HNOI2007]梦幻岛宝珠 背包

    题目 https://lydsy.com/JudgeOnline/problem.php?id=1190 题解 好神仙的一道题啊. 既然 \(w_i = a_i\cdot 2^{b_i}\),那么不妨 ...

  7. 算法 识别有效ip地址和掩码并做统计

    题目描述 请解析IP地址和对应的掩码,进行分类识别.要求按照A/B/C/D/E类地址归类,不合法的地址和掩码单独归类. 所有的IP地址划分为 A,B,C,D,E五类 A类地址1.0.0.0~126.2 ...

  8. hive中为分区表增加字段需要注意默认不会修改已有分区的字段,导致查询时新增字段为null

    若向hive表添加字段,通常会使用下面这种语句 alter table default.testparquet add columns(c8 string); 但是对于分区表来说, 1. 若新建的分区 ...

  9. markdown解析与着色

    markdown解析与着色 简介 最近在调整博客园博客样式,使用markdown发表的博客.这个不要太好用,有道云+markdown简直绝配,可以发在任何支持markdwon的博客网站,样式基本不会走 ...

  10. vue 生命周期函数详解

    beforeCreate( 创建前 ) 在实例初始化之后,数据观测和事件配置之前被调用,此时组件的选项对象还未创建,el 和 data 并未初始化,因此无法访问methods, data, compu ...