php curl rst,CURL错误:Recv失败:通过对等方重置连接 - PHP Curl
我有這個奇怪的錯誤, CURL ERROR: Recv failure: Connection reset by peer
這就是它發(fā)生的方式,如果我沒有連接到服務(wù)器并突然試圖通過PHP中的CURL連接到服務(wù)器我得到錯誤 . 當(dāng)我再次運行CURL腳本時,錯誤消失,然后一直運行良好,如果我讓遠(yuǎn)程服務(wù)器空閑大約30分鐘或重新啟動遠(yuǎn)程服務(wù)器并嘗試再次連接,我再次收到錯誤 . 所以似乎連接是空閑的,然后突然服務(wù)器喚醒然后工作然后再次睡眠 .
這就是我的CURL腳本的外觀 .
$url = Yii::app()->params['pdfUrl'];
$body = 'title='.urlencode($title).'&client_url='.Yii::app()->params['pdfClientURL'].'&client_id='.Yii::app()->params['pdfClientID'].'&content='.urlencode(htmlentities($content));
$c = curl_init ($url);
$body = array(
"client_url"=>Yii::app()->params['pdfClientURL'],
"client_id"=>Yii::app()->params['pdfClientID'],
"title"=>urlencode($title),
"content"=>urlencode($content)
);
foreach($body as $key=>$value) { $body_str .= $key.'='.$value.'&'; }
rtrim($body_str,'&');
curl_setopt ($c, CURLOPT_POST, true);
curl_setopt ($c, CURLOPT_POSTFIELDS, $body_str);
curl_setopt ($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($c, CURLOPT_CONNECTTIMEOUT , 0);
curl_setopt ($c, CURLOPT_TIMEOUT , 20);
$pdf = curl_exec ($c);
$errorCode = curl_getinfo($c, CURLINFO_HTTP_CODE);
$curlInfo = curl_getinfo($c);
$curlError = curl_error($c);
curl_close ($c);
我完全沒有想法和解決方案,請幫助,我會很感激!!!
如果我詳細(xì)說明輸出,看看會發(fā)生什么
curl_setopt ($c, CURLOPT_VERBOSE, TRUE);
curl_setopt($c, CURLOPT_STDERR, $fp);
我得到以下內(nèi)容
* About to connect() to 196.41.139.168 port 80 (#0)
* Trying 196.x.x.x... * connected
* Connected to 196.x.x.x (196.x.x.x) port 80 (#0)
> POST /serve/?r=pdf/generatePdf HTTP/1.1
Host: 196.x.x.x
Accept: */*
Content-Length: 7115
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
* Recv failure: Connection reset by peer
* Closing connection #0
012 20:23:49 GMT
< Server: Apache/2.2.15 (CentOS)
< X-Powered-By: PHP/5.3.3
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
* Closing connection #0
我在下面的腳趾中添加了刪除默認(rèn) Headers 但仍然沒有運氣:
curl_setopt ($c, CURLOPT_HTTPHEADER, array( 'Expect:' ) );
> Accept: */* Content-Length: 8414 Content-Type:
> application/x-www-form-urlencoded
>
> * Recv failure: Connection reset by peer
> * Closing connection #0 r: Apache/2.2.15 (CentOS) < X-Powered-By: PHP/5.3.3 < Connection: close < Transfer-Encoding: chunked <
> Content-Type: text/html; charset=UTF-8 <
> * Closing connection #0
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的php curl rst,CURL错误:Recv失败:通过对等方重置连接 - PHP Curl的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 温斯顿英语 PHP,温斯顿英语
- 下一篇: php 直接定义 和 construct