System Runtime Error Read timed out

一,问题描述


服务器(CO)同时请求多个接口(A,B,C,D,E,X,F),D报请求超时,其他正常;本地用同样逻辑代码向D发起访问请求,正常。减少CO发送字段正常。A,B,C,D,E,X,F为同一套代码。

file_get_contents或者cURL函数都可用来发送POST请求。当需要发送的数据(xml字符串)较多时,两类函数都有可能出现问题。

1.1 System Runtime Error:Read timed out
用curl_getinfo获取请求信息
array(27){["url"]=>string(59)"http://yeedupay.net/payserver/x2xpay/platformRequest.action["content_type"]=>string(23)"text/html;charset=UTF-8"["http_code"]=>int(500)["header_size"]=>int(291)["request_size"]=>int(179)["filetime"]=>int(-1)["ssl_verify_result"]=>int(0)["redirect_count"]=>int(0)["total_time"]=>float(20.38638)["namelookup_time"]=>float(0.004135)["connect_time"]=>float(0.183697)["pretransfer_time"]=>float(0.183761)["size_upload"]=>float(2263)["size_download"]=>float(3622)["speed_download"]=>float(177)["speed_upload"]=>float(111)["download_content_length"]=>float(3622)["upload_content_length"]=>float(2263)["starttransfer_time"]=>float(1.184948)["redirect_time"]=>float(0)["redirect_url"]=>string(0)""["primary_ip"]=>string(13)"103.91.10.146"["certinfo"]=>array(0){}["primary_port"]=>int(80)["local_ip"]=>string(13)"172.17.68.228"["local_port"]=>int(42208)["request_header"]=>string(179)"POST/payserver/x2xpay/platformRequest.actionHTTP/1.1Host:yeedupay.netAccept:*/*Content-Type:text/xml,Content-Length:2263Content-Length:2263Expect:100-continue"}

二,减少发送数据可以请求成功


三,代码把请求入参分组发送,需要接口update语句支持。

$arrheader=array("code"=>$postData['code'],"name"=>$postData['name'],"feeStatic"=>$postData['feeStatic'],"feeRate"=>$postData['feeRate'],"clearingCycle"=>$postData['clearingCycle']);unset($postData['code']);unset($postData['name']);unset($postData['feeStatic']);unset($postData['feeRate']);unset($postData['clearingCycle']);$arrbody=array_chunk($postData,2,true);foreach($arrbodyas$key=>$value){$resdata=array_merge($arrheader,$value);$res=$obj->channelOperationApi($platform_id,$resdata);}

备注:
1.1.1
doPostData($url,$data,$contentType='text/xml'){$opts=array('http'=>array('method'=>'POST','header'=>'content-type:'.$contentType."Content-Length:".strlen($data)."\r\n",'content'=>$data),);$context=stream_context_create($opts);$result=file_get_contents($url,true,$context);return$result;}

1.1.2
http_request($url,$data){$ch=curl_init();curl_setopt($ch,CURLOPT_CUSTOMREQUEST,'POST');curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);$res=curl_exec($ch);curl_close($ch);return$res;}

相关文档

评论0条