日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php curl rst,CURL错误:Recv失败:通过对等方重置连接 - PHP Curl

發(fā)布時間:2025/3/20 php 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php curl rst,CURL错误:Recv失败:通过对等方重置连接 - PHP Curl 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我有這個奇怪的錯誤, 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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。