我遇到大卷曲问题。
我得到了
- nread< = 0,服务器已关闭,无法接受
- 传输已关闭且剩余未完成的读取数据
并且内容部分传递
GET /stats/?stats_breakdown=track__track&campaign=&search_criteria=2&period=0&date_month=11&date_day=03&date_year=2015&start_date_month=11&start_date_day=03&start_date_year=2015&end_date_month=12&end_date_day=31&end_date_year=2014 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
Host: domain.com
Accept: */*
Cookie: sessionid=xxg4gglsm7o3b224wihqz8od19wl31h1; csrftoken=JBpLxNtgAVvDEw2wNqvBnRmzDJIjxL6C
Cache-Control: no-cache
Connection: Keep-Alive
Keep-Alive: 600
Accept-Language: en-us
X-CSRFToken: SeN9bHryRK8FWLTLJIs5c6u9AZ47a8pR
Content-Type: application/x-www-form-urlencoded
Origin: https://domain.com
Referer: https://domain.com
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Server: nginx/1.8.0
< Date: Wed, 04 Nov 2015 12:54:05 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< Vary: Cookie, Accept-Language
< P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
< Content-Language: en
* Replaced cookie csrftoken="JBpLxNtgAVvDEw2wNqvBnRmzDJIjxL6C" for domain domain.com, path /, expire 1478091245
< Set-Cookie: csrftoken=JBpLxNtgAVvDEw2wNqvBnRmzDJIjxL6C; expires=Wed, 02-Nov-2016 12:54:05 GMT; Max-Age=31449600; Path=/; secure
<
* nread <= 0, server closed connection, bailing
* transfer closed with outstanding read data remaining
* Closing connection #0
这是我使用的php配置
function getHeaders()
{
$headers = array();
$headers[] = 'Cache-Control: no-cache';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Keep-Alive: 600';
$headers[] = 'Accept-Language: en-us';
$headers[] = 'X-CSRFToken: SeN9bHryRK8FWLTLJIs5c6u9AZ47a8pR';
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Origin: https://domain.com';
$headers[] = 'Referer: https://domain.com';
return $headers;
}
curl_setopt($connection, CURLOPT_URL, $url);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($connection, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($connection, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($connection, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($connection, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($connection, CURLOPT_CONNECTTIMEOUT ,550000000);
curl_setopt($connection, CURLOPT_TIMEOUT, 5500000000); //timeout in seconds
curl_setopt($connection, CURLOPT_HTTPHEADER, getHeaders());
curl_setopt($connection, CURLOPT_VERBOSE, 1);
答案 0 :(得分:8)
好的,经过一些搜索和IRC聊天后我找到了解决方案,但并不是100%确定原因是什么。看起来保持活动不足以保持连接继续进行。将在此处发布解决方案,希望我可以帮助某人。
对我有帮助的是添加
--keepalive-time 2
卷曲选项的解释
--keepalive-time <seconds>
此选项设置连接之前需要保持空闲的时间 发送keepalive探针和个体keepalive之间的时间 探头。它目前在提供的操作系统上有效 TCP_KEEPIDLE和TCP_KEEPINTVL套接字选项(意思是Linux,最近的 AIX,HP-UX等)。如果--no-keepalive是,则此选项无效 用过的。 (在7.18.0中添加)
如果多次使用此选项,将使用最后一个选项。如果 未指定,该选项默认为60秒。
看起来默认设置太高,无法保持连接打开。
以下是我用于通话的完整命令
curl URL -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,et;q=0.6,nl;q=0.4' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Connection: keep-alive' --compressed -v --keepalive-time 2
我在osx上运行这个版本的curl
curl 7.43.0 (x86_64-apple-darwin15.0) libcurl/7.43.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
如果有人想在PHP curl中使用此选项,则自PHP 5.5起可以使用--keepalive-time选项。您可以按如下方式使用它:
curl_setopt($connection, CURLOPT_TCP_KEEPALIVE, 1);
curl_setopt($connection, CURLOPT_TCP_KEEPIDLE, 2);
希望这可以帮助有人解决同样的问题!
答案 1 :(得分:5)
遇到类似的问题,我的服务器落后于nginx。如果curl直接连接到服务器,但是如果curl通过nginx连接到服务器,则curl能够接收响应,curl会抛出错误
&#34;会话*转移关闭,剩余未完成的读取数据*关闭连接0卷曲:(18)传输已关闭且剩余未完成的读取数据
当我使用浏览器连接到相同的nginx URL时,Response显示正常。这很奇怪,当我尝试使用curl连接到相同的nginx URL时,它抛出了错误。
比较浏览器和curl发送的标头。我发现浏览器能够收到响应,因为下面的标题卷曲没有发送
location / {
proxy_buffering off;
}
使用curl在头部发送,它工作正常。所以,以上标题正在做的是压缩对gzip的响应,从而减少响应大小。
经过一番挖掘,发现nginx无法发送任何有效载荷&gt; 80KB。在浪费了大量时间之后,发现问题在于nginx缓冲和nginx在nginx.conf中添加了以下proxy_buffering属性之后就像魅力一样工作
Dim oConn As ADODB.Connection
Sub Macro1()
Set oConn = New ADODB.Connection
oConn.ConnectionString = "DRIVER={MySQL ODBC 5.2 ANSI Driver};" _
& "SERVER=server;" _
& "DATABASE=DB;" _
& "UID=USER;PWD=PW; OPTION=3"
oConn.Open
接受的答案没有解决我的问题。写下这个答案,这样任何人都不必浪费时间,如果他们面临与我一样的问题。
答案 2 :(得分:1)
libcurl只告诉你服务器以不干净的方式切断了连接,而且它没有提供它承诺要做的数据。看起来chunked-encoding并没有表示转移的结束。
浏览器因其收到的内容非常自由而臭名昭着,所以他们忽略了各种协议违规行为并且与libcurl相比更为广泛。
答案 3 :(得分:-1)
遇到类似问题,我的服务器也位于nginx后面。 Web服务器的(烧瓶)日志中没有错误,但是在Nginx日志中发现了一些错误消息。
[crit] 31054#31054:* 269464 open()“ / var / cache / nginx / proxy_temp / 3/45/0000000453”失败(13:权限被拒绝)
我通过更正目录'/ var / cache / nginx'的权限来解决此问题