question

Upvotes
Accepted
50 9 14 24

curl: (18) transfer closed with 803828224 bytes remaining to read

While trying to download files ( in GB size), we are getting the above message. We are using curl command to retrive the data. Anyone faced same issue earlier? Is there any solution for the same?

Command is as below.

curl -k -X GET -H 'Authorization: Token xxxxxxxxxxxxxxxxxxxxxxx' -o NAS-2017-07-25-NORMALIZEDMP-Data-1-of-1.csv.gz https://10.192.6.221/RestApi/v1/StandardExtractions/UserPackageDeliveries%28%270x05cf06a3fedb3026%27%29/%24value

tick-history-rest-apierror
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
11.3k 25 8 14

@Ayan

It seems like the connection has been closed, while the file has been downloading. It might be connection issue between your machine and the firewall.

Curl provides an option to resume download. This option may help you continue the download, once the issue occurs for huge file. Below is the sample command. It can check download progress from the existing file name, and then continue downloading the data.

curl -k -H 'Authorization:  Token xxxxxxxxxxxxxxxxxxxxxxx' -o NAS-2017-07-25-NORMALIZEDMP-Data-1-of-1.csv.gz -C - https://10.192.6.221/RestApi/v1/StandardExtractions/UserPackageDeliveries%28%270x05cf06a3fedb3026%27%29/%24value

Hope this helps.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
50 9 14 24

Hi, Thanks for the reply, but it actually doesnot resolve my problem. Your suggestion is to download the file with -C option which will resume the download from the same place where it left. Now I have a few questions here.

1. In worst case scenario, what is the guarantee that it will not terminate the download again after resuming it?

2. If it terminates too, then how many times we must try to complete the download?

3. How will we know that the entire files got downloaded?

Hope I am able to elaborate my problem. Please help.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
11.3k 25 8 14

@Ayan

Yes. The curl option should not solve the issue. It is a workaround once the issue occurs, so you do not need to re-download the file from begining. The issue can reoccur again on this command, once there is a connection closed issue. If the entire file gets the download, the command will exit without any error message.

I am able to download the same file with the curl command in my environment, so I suspect that the issue is in the network and firewall in your environment. Could you contact your administrator to verify your network and firewall?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks for the reply, I will contact my network team on the same.

Upvote
47.2k 109 44 60

@Ayan

I got the same error when using netsh command to do port forwarding.

C:\netsh interface portproxy add v4tov4 listenport=443 listenaddress=127.0.0.1 connectport=443 connectaddress=hosted.datascopeapi.reuters.com

Then, I used this curl command on Windows to download a VBD file.

curl -k -X GET -H "Authorization: Token <token>" -o NAS-2017-07-25-NORMALIZEDMP-Data-1-of-1.csv.gz https://127.0.0.1/RestApi/v1/StandardExtractions/UserPackageDeliveries('0x05cf06a3fedb3026')/$value

After that, I cut the connection between netsh and datascope.

The curl command showed the following error:

curl: (18) transfer closed with 1789333843 bytes remaining to read

Like Veerapath mentioned, you need to contact the firewall admin to verify the connection and settings.

To remove the netsh port forwarding, I used the following command.

C:\netsh interface portproxy delete v4tov4 listenport=443 listenaddress=127.0.0.1

netsh.png (3.8 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
50 9 14 24

We will use -C option in Curl to continue download if "Connection Close" occurs.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.