- The current upload rate is = 83.6318 KB/s
- The current SD_CARD rate is = 1133.5957 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6452512
- amount of data read from sd = 8096
- [0;32mI (94970) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (94975) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (94980) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95018) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95040) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95041) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95045) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95050) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95056) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95061) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 82.8259 KB/s
- The current SD_CARD rate is = 1182.1600 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6460608
- amount of data read from sd = 8096
- [0;32mI (95084) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95088) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95094) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95131) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95153) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95153) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95159) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95163) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95168) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95174) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.3725 KB/s
- The current SD_CARD rate is = 1186.1720 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6468704
- amount of data read from sd = 8096
- [0;32mI (95196) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95201) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95207) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95242) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95263) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95263) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95269) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95273) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95278) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95284) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 85.7661 KB/s
- The current SD_CARD rate is = 933.7275 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6476800
- amount of data read from sd = 8096
- [0;32mI (95308) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95311) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95316) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95353) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95375) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95375) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95380) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95385) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95391) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95396) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.9062 KB/s
- The current SD_CARD rate is = 905.5060 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6484896
- amount of data read from sd = 8096
- [0;32mI (95419) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95423) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95428) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95465) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95487) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95487) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95493) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95497) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95502) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95508) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 84.2297 KB/s
- The current SD_CARD rate is = 1116.6943 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6492992
- amount of data read from sd = 8096
- [0;32mI (95530) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95535) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95540) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95577) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95599) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95600) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95604) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95609) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95615) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95620) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.6318 KB/s
- The current SD_CARD rate is = 1100.2896 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6501088
- amount of data read from sd = 8096
- [0;32mI (95643) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95647) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95653) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95689) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95712) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95712) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95719) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95722) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95727) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95733) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.3725 KB/s
- The current SD_CARD rate is = 1114.3209 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6509184
- amount of data read from sd = 8096
- [0;32mI (95755) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95760) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95765) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95801) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95825) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95825) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95831) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95835) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95840) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95846) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.0950 KB/s
- The current SD_CARD rate is = 1170.2858 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6517280
- amount of data read from sd = 8096
- [0;32mI (95869) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95873) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95879) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (95914) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (95938) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (95938) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (95943) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (95947) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (95953) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (95959) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.5785 KB/s
- The current SD_CARD rate is = 1174.2173 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6525376
- amount of data read from sd = 8096
- [0;32mI (95981) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (95985) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (95991) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (96028) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (96051) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (96051) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (96056) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (96061) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (96066) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (96072) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.1016 KB/s
- The current SD_CARD rate is = 1087.7345 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6533472
- amount of data read from sd = 8096
- [0;32mI (96094) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (96098) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (96104) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (96141) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (96163) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (96163) mbedtls: ssl_tls.c:2770 message length: 8125, out_left: 8125
- [0m
- [0;32mI (96168) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 8125 (-0xffffe043)
- [0m
- [0;32mI (96173) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (96178) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (96184) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 83.7922 KB/s
- The current SD_CARD rate is = 954.4078 KB/s
- amount of data sent = 8096
- TOTAL AMOUNT OF DATA READ = 6541568
- amount of data read from sd = 3232
- [0;32mI (96206) mbedtls: ssl_tls.c:8619 => write
- [0m
- [0;32mI (96211) mbedtls: ssl_tls.c:3337 => write record
- [0m
- [0;32mI (96216) mbedtls: ssl_tls.c:1441 => encrypt buf
- [0m
- [0;32mI (96244) mbedtls: ssl_tls.c:1777 <= encrypt buf
- [0m
- [0;32mI (96262) mbedtls: ssl_tls.c:2751 => flush output
- [0m
- [0;32mI (96262) mbedtls: ssl_tls.c:2770 message length: 3261, out_left: 3261
- [0m
- [0;32mI (96266) mbedtls: ssl_tls.c:2775 ssl->f_send() returned 3261 (-0xfffff343)
- [0m
- [0;32mI (96272) mbedtls: ssl_tls.c:2803 <= flush output
- [0m
- [0;32mI (96277) mbedtls: ssl_tls.c:3470 <= write record
- [0m
- [0;32mI (96283) mbedtls: ssl_tls.c:8647 <= write
- [0m
- The current upload rate is = 36.5239 KB/s
- The current SD_CARD rate is = 0.0000 KB/s
- amount of data sent = 3232
- TOTAL AMOUNT OF DATA READ = 6544800
- [0;32mI (96594) mbedtls: ssl_tls.c:8207 => read
- [0m
- [0;32mI (96595) mbedtls: ssl_tls.c:4305 => read record
- [0m
- [0;32mI (96595) mbedtls: ssl_tls.c:2532 => fetch input
- [0m
- [0;32mI (96599) mbedtls: ssl_tls.c:2693 in_left: 0, nb_want: 5
- [0m
- [0;32mI (96606) mbedtls: ssl_tls.c:2717 in_left: 0, nb_want: 5
- [0m
- [0;32mI (96612) mbedtls: ssl_tls.c:2718 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
- [0m
- [0;32mI (96620) mbedtls: ssl_tls.c:2738 <= fetch input
- [0m
- [0;32mI (96626) mbedtls: ssl_tls.c:2532 => fetch input
- [0m
- [0;32mI (96631) mbedtls: ssl_tls.c:2693 in_left: 5, nb_want: 377
- [0m
- [0;32mI (96639) mbedtls: ssl_tls.c:2717 in_left: 5, nb_want: 377
- [0m
- [0;32mI (96644) mbedtls: ssl_tls.c:2718 ssl->f_recv(_timeout)() returned 372 (-0xfffffe8c)
- [0m
- [0;32mI (96652) mbedtls: ssl_tls.c:2738 <= fetch input
- [0m
- [0;32mI (96660) mbedtls: ssl_tls.c:1790 => decrypt buf
- [0m
- [0;32mI (96664) mbedtls: ssl_tls.c:2372 <= decrypt buf
- [0m
- [0;32mI (96670) mbedtls: ssl_tls.c:4379 <= read record
- [0m
- [0;32mI (96674) mbedtls: ssl_tls.c:8495 <= read
- [0m
- Server
- nginx/1.14.0 (Ubuntu)
- Date
- Sun, 10 Mar 2019 01:15:22 GMT
- Content-Type
- text/html
- Content-Length
- 182
- Connection
- keep-alive
- <html>
- <head><title>502 Bad Gateway</title></head>
- <body bgcolor="white">
- <center><h1>502 Bad Gateway</h1></center>
- <hr><center>nginx/1.14.0 (Ubuntu)</center>
- </body>
- </html>
- THEEEEE RESPONSE IS CHUNKED!!!!
- amount of headers read = 182
- The response code is: 502
- The current download rate is = 0.0000 KB/s
- amount of data read = 266
- [0;31mE (96731) HTTP_CLIENT: HTTP CLOSE request failed: ESP_FAIL[0m
- The total upload time is = 90.9440 seconds
- [0;32mI (96738) HTTP_CLIENT: HTTP CLEANUP Status = 502, content_length = 182[0m
I'm completely lost at this point. I'm trying to do a put request while reading in data from an sdcard. To test it I have written a function as described here: https://docs.espressif.com/projects/esp ... ttp-stream
It fails every time though, I did run the esp_http_client example code and all of the tests passed. I've also tried to run the code I wrote below with various different sites and a local server. It fails each time. I'm quite new to this so not entirely sure what I'm doing wrong. The PUT request below is one of many functions (the rest work), so for now I'm only posting the relevant portion below:
- void Send_data(char* tstamp,esp_http_client_handle_t client,esp_http_client_config_t config){
- //SEND DATA TO SERVER IN BATCHES
- // SET HEADERS AND HAVE A FIXED CONTENT LENGTH FOR TESTING
- esp_http_client_set_method(client, HTTP_METHOD_PUT);
- esp_http_client_set_header(client, "User-Agent", "python-requests/2.18.4");
- esp_http_client_set_header(client,"Accept-Encoding","gzip, deflate");
- esp_http_client_set_header(client,"Accept","*/*");
- esp_http_client_set_header(client,"Connection","keep-alive");
- esp_http_client_set_header(client,"Content-length","1024");
- //esp_http_client_set_header(client,"Cookie",cookie);
- //SET THE URL FOR TESTING TO HTTPBIN
- esp_http_client_set_url(client, "http://httpbin.org/put");
- //OPEN A CONNECTION AND ENSURE THE LENGTH IS LONGER
- //THAN THE DATA TO BE WRITTEN WITH THE WRITE FUNCTION
- printf(" \n OPEN \n");
- err = esp_http_client_open(client,2000);
- if (err == ESP_OK) {
- ESP_LOGI(TAG, "HTTP OPEN Status = %d, content_length = %d",
- esp_http_client_get_status_code(client),
- esp_http_client_get_content_length(client));
- } else {
- ESP_LOGE(TAG, "HTTP OPEN request failed: %s", esp_err_to_name(err));
- }
- /
- printf(" \n WRITE \n");
- //READ DATA IN FROM SDCARD TO BUFFER
- int ret = 0;
- ret= fread(buffer,1,1024,f);
- printf("\n %d \n",ret);
- //WRITE DATA TO HTTPBIN
- err= esp_http_client_write(client, buff11, ret);
- if (err == ESP_OK) {
- ESP_LOGI(TAG, "HTTP WRITE Status = %d, content_length = %d",
- esp_http_client_get_status_code(client),
- esp_http_client_get_content_length(client));
- } else {
- ESP_LOGE(TAG, "HTTP WRITE request failed: %s", esp_err_to_name(err));
- }
- // FETCH THE RESPONSE HEADERS
- err = esp_http_client_fetch_headers(client);
- if (err == ESP_OK) {
- ESP_LOGI(TAG, "HTTP WRITE Status = %d, content_length = %d",
- esp_http_client_get_status_code(client),
- esp_http_client_get_content_length(client));
- } else {
- ESP_LOGE(TAG, "HTTP WRITE request failed: %s", esp_err_to_name(err));
- }
- printf(" \n CLOSE \n");
- err = esp_http_client_read(client,buff12,1000);
- if (err == ESP_OK) {
- ESP_LOGI(TAG, "HTTP READ_HEADER Status = %d, content_length = %d",
- esp_http_client_get_status_code(client),
- esp_http_client_get_content_length(client));
- } else {
- ESP_LOGE(TAG, "HTTP READ_HEADER request failed: %s", esp_err_to_name(err));
- }
- printf("\n %s \n",buff12);
- //CLOSE THE CONNECTION - CLEANUP ISN'T DONE HERE BUT IN THE NEXT REQUEST
- err = esp_http_client_close(client);
- if (err == ESP_OK) {
- ESP_LOGI(TAG, "HTTP CLOSE Status = %d, content_length = %d",
- esp_http_client_get_status_code(client),
- esp_http_client_get_content_length(client));
- } else {
- ESP_LOGE(TAG, "HTTP CLOSE request failed: %s", esp_err_to_name(err));
- }
- fclose(f);
- free(buff11);
- free(buff12);
- }
This code returns the following output:
- OPEN
- I (7180) HTTP_CLIENT: HTTP OPEN Status = 200, content_length = 38
- WRITE
- 1024E (7180) HTTP_CLIENT: HTTP WRITE request failed: ERROR
- E (12180) HTTP_CLIENT: HTTP WRITE request failed: ESP_FAIL
- CLOSE
- E (17180) HTTP_CLIENT: HTTP READ_HEADER request failed: ERROR
- <h1 style='color:blue'>logged in!</h1>
- I (17180) HTTP_CLIENT: HTTP CLOSE Status = -1, content_length = 38
- EXIT SEND FUNCTION
- I (17180) example: Data sent to database
Any help will really be appreciated as I'm completely lost!
TIA!