curl error 18 - transfer closed with outstanding read data remaining
I bet this is related to a wrong Content-Length
header sent by the peer.
My advice is to let curl set the length by itself.
Curl: transfer closed with outstanding read data remaining
Okay, after some searching and IRC chat's I found solution, but not 100% sure what the cause is. Looks like the keep-alives weren't send enough to keep the connection going on. Will post the solution here, hopefully I can help someone out.
What helped for me is adding
--keepalive-time 2
An explanation of the curl option
--keepalive-time <seconds>
This option sets the time a connection needs to remain idle before
sending keepalive probes and the time between individual keepalive
probes. It is currently effective on operating systems offering the
TCP_KEEPIDLE and TCP_KEEPINTVL socket options (meaning Linux, recent
AIX, HP-UX and more). This option has no effect if --no-keepalive is
used. (Added in 7.18.0)If this option is used several times, the last one will be used. If
unspecified, the option defaults to 60 seconds.
Looks like the default was too high to keep my connection open.
Here is the full command I used for my call
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
And I'm running this version of curl on osx
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
If someone would like to have this option used in PHP curl, the --keepalive-time option is available since PHP 5.5. You can use it as following:
curl_setopt($connection, CURLOPT_TCP_KEEPALIVE, 1);
curl_setopt($connection, CURLOPT_TCP_KEEPIDLE, 2);
Hope this helps someone struggling with the same issue!
curl error 18, attempting to solve problem using SO answer 1759956
The connection is just getting closed by the server after 30 seconds.
You can try to increase speed of the client but if the server is not delivering enough in the limited time you get the message even with fast connection.
In the case of the example http://corpus-db.org/api/author/Dickens,%20Charles/fulltext I got a larger amount of content with direct output:
curl http://corpus-db.org/api/author/Dickens,%20Charles/fulltext
while the amount was smaller while writing in a file (already ~47MB in 30 seconds):
curl -o Dickens,%20Charles http://corpus-db.org/api/author/Dickens,%20Charles/fulltext
Resuming file transfers can be tried, but on the example server it's not supported:
curl -C - -o Dickens,%20Charles http://corpus-db.org/api/author/Dickens,%20Charles/fulltext
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
So there might be options to optimize the request, to increase the connection-speed or the cache-size but if you reached the limit and never get more data in the limited time you can't do anything.
The cUrl manual can be found here: https://curl.haxx.se/docs/manual.html
The following links won't help you but perhaps are interesting:
The repository for the data-server can be found here: https://github.com/JonathanReeve/corpus-db
The documentation for the used web-server can be found here: https://hackage.haskell.org/package/warp-3.2.13
GuzzleHttp\Client cURL error 18: transfer closed
I have resolved this issue , Maybe it will help someone
$client = new Client();
$result = $client->request("POST", $this->url,
[
'headers' => [
'Authorization' => 'Bearer ' . $this->ApiToken,
'Accept-Encoding' => 'gzip, deflate', //new line added
],
]);
$content = $result->getBody()->getContents();
cURL error 18: transfer closed with outstanding read data remaining
I had the same problem. I changed,
MAIL_ENCRYPTION=null to
MAIL_ENCRYPTION=tls
and run command
php artisan config:cache
curl error 18 transfer closed with outstanding read data remaining
This error is being generated by the fact that the datetime= paramater is being passed in with non encoded non URL friendly characters... (eg. space).
The fix to this would be to find a way to convert the $datetime to a URLEncoded String.
eg. convert:
2017/03/01 08:50:56
TO
2017%2F03%2F01%2008%3A50%3A56
See the following discussion for one method to accomplish this.
Post JSON data to Rest with URLEncoded query paramaters
error: RPC failed; curl transfer closed with outstanding read data remaining
After few days, today I just resolved this problem. Generate ssh key, follow this article:
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
Declare it to
- Git provider (GitLab what I am using, GitHub).
- Add this to local identity.
Then clone by command:
git clone username@mydomain.com:my_group/my_repository.git
And no error happen.
The above problem
error: RPC failed; curl 18 transfer closed with outstanding read data
remaining
because have error when clone by HTTP protocol (curl
command).
And, you should increment buffer size:
git config --global http.postBuffer 524288000
Related Topics
How to Prevent PHP Sessions Being Shared Between Different Apache Vhosts
Are Objects in PHP Assigned by Value or Reference
Is There a Biginteger Class in PHP
Remove .PHP Extension with PHP
Codeigniter Cron Job Not Working
PHP - Secure Member-Only Pages with a Login System
Using Wildcards in Prepared Statement - MySQLi
Compare Multidimensional Arrays in PHP
Sorting Laravel Collection via Array of Id'S
Mcrypt_Encrypt to Openssl_Encrypt, and Openssl_Zero_Padding Problems
Parse a JavaScript File Through PHP
Could Not Instantiate Mail Function. Why This Error Occurring
Prevent Innodb Auto Increment on Duplicate Key
How to Install/Enable the PHP Phar Extension
Composer Installing: the JSON Extension Is Missing
Php: Using a Variable Inside a Double Quotes