【Ongoing】OTA HEAD request has 4 extra bytes of NULL(\0) data payload (BUG)

zymxjtu
Posts: 3
Joined: Sun Jun 12, 2016 11:54 am

【Ongoing】OTA HEAD request has 4 extra bytes of NULL(\0) data payload (BUG)

Postby zymxjtu » Sun Jun 12, 2016 12:35 pm

Hi,

When I'm working on the OTA of ESP8266, I found out that the OTA works when I use Apache or Nginx as server, but it does not work with my Node.js server. I took a lot of time to find out why. In the end, I found out that ESP8266 send out extra 4 bytes 0 at the the end of the HEAD request.

According to HTTP 1.1 spec, HEAD request should not have data payload, so Node.js http parser will treat the HEAD request from ESP8266 as malformed request and close the socket. While Apache/Nginx seems will be able to tolerate it.

Are there any reason why this extra 4 bytes 0 are attached? Can espressif please take a look at it and fix this bug in next SDK release?

I'm using NON-OS SDK 1.5.2 by the way. Tested latest SDK 1.5.4 has problem also.

I have tired sending request using curl to the Node.js server which works well, and using wireshark to capture the packet send by curl and ESP8266, after doing compare, found out this 4 extra bytes 0 problem.

Image
Image

ESP_Faye
Posts: 1643
Joined: Mon Oct 27, 2014 11:08 am

Re: OTA HEAD request has 4 extra bytes of NULL(\0) data payload (BUG)

Postby ESP_Faye » Mon Jun 13, 2016 5:59 pm

Hi,

The OTA HEAD is set by the application, not SDK, you need to check your application source code, for example, the "server->url" below

Code: Select all

os_sprintf(server->url, "GET /%s HTTP/1.0\r\nHost: "IPSTR":%d\r\n"pheadbuffer"",
               user_bin, IP2STR(server->ip),
               8080);

if (system_upgrade_start(server) == false) {
        ESP_DBG("upgrade is already started\n");
    }

zymxjtu
Posts: 3
Joined: Sun Jun 12, 2016 11:54 am

Re: OTA HEAD request has 4 extra bytes of NULL(\0) data payload (BUG)

Postby zymxjtu » Fri Jun 17, 2016 9:33 pm

Espressif_Faye wrote:Hi,

The OTA HEAD is set by the application, not SDK, you need to check your application source code, for example, the "server->url" below

Code: Select all

os_sprintf(server->url, "GET /%s HTTP/1.0\r\nHost: "IPSTR":%d\r\n"pheadbuffer"",
               user_bin, IP2STR(server->ip),
               8080);

if (system_upgrade_start(server) == false) {
        ESP_DBG("upgrade is already started\n");
    }


Hi, Thanks for the reply.

I'm quite sure(if not 100%) I did things correctly. I didn't attach '\0'(NULL) behind. I believe it is inside the espressif SDK OTA, where it construct the "HEAD" message out of the "GET" server->url provided by user. (Note that user does not even provide the "HEAD"message. the SDK somehow takes the server->url user provided, and construct the HEAD message. Check the example you provided, os_sprintf with "GET" not "HEAD"). Can please check the implementation of OTA in the SDK and find out where those 4 bytes NULL attached? I strongly believe there is bug in the OTA of the SDK. Thanks.

ESP_Faye
Posts: 1643
Joined: Mon Oct 27, 2014 11:08 am

Re: OTA HEAD request has 4 extra bytes of NULL(\0) data payload (BUG)

Postby ESP_Faye » Mon Jun 20, 2016 3:20 pm

Hi,

Sorry that we can not reproduce your problem.

Please provide your test code, we will help debug it.

Thanks for your interest in ESP8266 !

zymxjtu
Posts: 3
Joined: Sun Jun 12, 2016 11:54 am

Re: OTA HEAD request has 4 extra bytes of NULL(\0) data payload (BUG)

Postby zymxjtu » Tue Jun 28, 2016 10:26 am

Espressif_Faye wrote:Hi,

Sorry that we can not reproduce your problem.

Please provide your test code, we will help debug it.

Thanks for your interest in ESP8266 !


Hi, Thanks. I have attached the code shared in dropbox:
https://dl.dropboxusercontent.com/u/37823220/ota.7z

Thanks.

Who is online

Users browsing this forum: No registered users and 3 guests