curl / Mailing Lists / curl-library / Single Mail

curl-library

Need help: stuck on upload speed of 4kb/s using libcurl 7.51.0

From: Sebastian Christ <Sebastian.Christ_at_softengine.de>
Date: Mon, 21 Nov 2016 21:33:11 +0000

Hi all,

this is the code I'm using to prepare and upload a file to a webservice:

bool ScSpeed4Trade_cURL::MakeRequest(qString Action, qString Request, qString &Response)
{
...
//Init CURL
CURL *curl_handle = curl_easy_init ();

curl_off_t Filesize = 20 * 1000000; //20mb
curl_easy_setopt (curl_handle, CURLOPT_MAXFILESIZE_LARGE, Filesize);

//Set Headers
struct curl_slist *HeaderList = NULL;
HeaderList = curl_slist_append (HeaderList, ActionStream.GetData ());
HeaderList = curl_slist_append (HeaderList, "Content-Type: text/xml;charset=UTF-8");
curl_easy_setopt (curl_handle, CURLOPT_HTTPHEADER, HeaderList);

curl_easy_setopt (curl_handle, CURLOPT_POST, 1L);
curl_easy_setopt (curl_handle, CURLOPT_USERAGENT, "Shopmanager 2.0");
curl_easy_setopt (curl_handle, CURLOPT_POSTFIELDSIZE, (curl_off_t)UploadDaten.DatenLen);

curl_easy_setopt (curl_handle, CURLOPT_READFUNCTION, ScSpeed4Trade_cURL::UploadCallback);
curl_easy_setopt (curl_handle, CURLOPT_READDATA, &UploadDaten);
curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, ScSpeed4Trade_cURL::DownloadCallback);
curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, &ResponseStream);

//Debug
FILE *dumpfile = fopen("curldump.txt", "wb");
curl_easy_setopt (curl_handle, CURLOPT_STDERR, dumpfile);
curl_easy_setopt (curl_handle, CURLOPT_VERBOSE, 1L);
//curl_easy_setopt (curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); //Zertifikat nicht abfragen
//CURL.setopt(CURLOPT_PROXY, "127.0.0.1:8888"); //Über Fiddler

//Credentials
curl_easy_setopt (curl_handle, CURLOPT_URL, URL);
curl_easy_setopt (curl_handle, CURLOPT_USERNAME, User);
curl_easy_setopt (curl_handle, CURLOPT_PASSWORD, Pass);
curl_easy_setopt (curl_handle, CURLOPT_CAINFO, Cert);

CURLcode RetVal = curl_easy_perform (curl_handle);
double average_speed = 0;
double bytes_uploaded = 0;
double total_upload_time = 0;

curl_easy_getinfo (curl_handle, CURLINFO_SPEED_UPLOAD, &average_speed);
curl_easy_getinfo (curl_handle, CURLINFO_SIZE_UPLOAD, &bytes_uploaded);
curl_easy_getinfo (curl_handle, CURLINFO_TOTAL_TIME, &total_upload_time);

//Cleanup
curl_slist_free_all (HeaderList);
curl_easy_cleanup (curl_handle);
fclose (dumpfile);
...
}

size_t ScSpeed4Trade_cURL::UploadCallback(char *ptr, size_t size, size_t nmemb, void *data)
{
if (!ptr) return 0;
if (size * nmemb <= 0) return 0;
Daten *Quelldaten = (Daten *)data;
if (!Quelldaten || Quelldaten->DatenLen <= 0) return 0;

MEMCPY (ptr, Quelldaten->DatenPtr, size);

Quelldaten->DatenPtr += size;
Quelldaten->DatenLen -= size;

return size;
}

size_t ScSpeed4Trade_cURL::DownloadCallback(char *ptr, size_t size, size_t nmemb, void *data)
{
if (!ptr) return 0;

qMemoryStream *Zieldaten = (qMemoryStream *)data;
if (!Zieldaten) return 0;

Zieldaten->Set (ptr, nmemb);

return nmemb;
}

My average upload speed lies around 3700 b/s regardless of the filesize (trie 500kb up to 2mb).
I should be able to do around 275 kb/s. curl.exe works fine for same webservice.

Heres the dump:
* Trying 144.76.44.231...
* TCP_NODELAY set
* Connected to api.emmida.com (144.76.44.231) port 8474 (#0)
* schannel: SSL/TLS connection with api.emmida.com port 8474 (step 1/3)
* schannel: checking server certificate revocation
* schannel: ALPN, offering http/1.1
* schannel: sending initial handshake data: sending 206 bytes...
* schannel: sent initial handshake data: sent 206 bytes
* schannel: SSL/TLS connection with api.emmida.com port 8474 (step 2/3)
* schannel: failed to receive handshake, need more data
* schannel: SSL/TLS connection with api.emmida.com port 8474 (step 2/3)
* schannel: encrypted data buffer: offset 2273 length 4096
* schannel: sending next handshake data: sending 166 bytes...
* schannel: SSL/TLS connection with api.emmida.com port 8474 (step 2/3)
* schannel: encrypted data buffer: offset 6 length 4096
* schannel: SSL/TLS connection with api.emmida.com port 8474 (step 2/3)
* schannel: encrypted data buffer: offset 85 length 4096
* schannel: SSL/TLS handshake complete
* schannel: SSL/TLS connection with api.emmida.com port 8474 (step 3/3)
* ALPN, server did not agree to a protocol
* schannel: stored credential handle in session cache
* Server auth using Basic with user 'webservice'
> POST /services/ecs-ws.ecs-wsHttpsSoap12Endpoint HTTP/1.1
Host: api.emmida.com:8474
Authorization: Basic d2Vic2VydmljZTpKd3N4OE5CQ3RBUW1rMlk=
User-Agent: Shopmanager 2.0
Accept: */*
SOAPAction:urn:updateItems
Content-Type: text/xml;charset=UTF-8
Content-Length: 421674
Expect: 100-continue

* schannel: client wants to read 16384 bytes
* schannel: encdata_buffer resized 17408
* schannel: encrypted data buffer: offset 0 length 17408
* schannel: encrypted data got 85
* schannel: encrypted data buffer: offset 85 length 17408
* schannel: decrypted data length: 25
* schannel: decrypted data added: 25
* schannel: decrypted data cached: offset 25 length 16384
* schannel: encrypted data buffer: offset 0 length 17408
* schannel: decrypted data buffer: offset 25 length 16384
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 25
* schannel: decrypted data buffer: offset 0 length 16384
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
* schannel: client wants to read 16384 bytes
* schannel: encrypted data buffer: offset 0 length 17408
* schannel: encrypted data got 1705
* schannel: encrypted data buffer: offset 1705 length 17408
* schannel: decrypted data length: 149
* schannel: decrypted data added: 149
* schannel: decrypted data cached: offset 149 length 16384
* schannel: encrypted data length: 1492
* schannel: encrypted data cached: offset 1492 length 17408
* schannel: decrypted data length: 5
* schannel: decrypted data added: 5
* schannel: decrypted data cached: offset 154 length 16384
* schannel: encrypted data length: 1423
* schannel: encrypted data cached: offset 1423 length 17408
* schannel: decrypted data length: 1228
* schannel: decrypted data added: 1228
* schannel: decrypted data cached: offset 1382 length 16384
* schannel: encrypted data length: 138
* schannel: encrypted data cached: offset 138 length 17408
* schannel: decrypted data length: 2
* schannel: decrypted data added: 2
* schannel: decrypted data cached: offset 1384 length 16384
* schannel: encrypted data length: 69
* schannel: encrypted data cached: offset 69 length 17408
* schannel: decrypted data length: 5
* schannel: decrypted data added: 5
* schannel: decrypted data cached: offset 1389 length 16384
* schannel: encrypted data buffer: offset 0 length 17408
* schannel: decrypted data buffer: offset 1389 length 16384
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 1389
* schannel: decrypted data buffer: offset 0 length 16384
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: text/xml;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Mon, 21 Nov 2016 21:02:34 GMT
<
* Curl_http_done: called premature == 0
* Connection #0 to host api.emmida.com left intact

What am I doing wrong? Please help!

Greetings,
Sebastian

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-11-21