arduino-libraries / ArduinoHttpClient

Arduino HTTP Client library
282 stars 170 forks source link

Sometimes server receives messed headers #75

Open tkralj opened 4 years ago

tkralj commented 4 years ago

Hello, i have a weird problem on ESP32 chip . After several days of continous work it looks like ArduinoHttpClient library messes up http headers and IIS sends wrong data.

For Example this is the code i use to send HTTP requests to the server:

HttpClient https(webApiServerName, 80);

https.beginRequest();

https.get(url);
https.sendHeader("Content-Type", "text/plain");
https.sendHeader("Content-Length", 0);
**https.sendHeader("api-key", cfg.sn);**
https.sendHeader("Authorization", AuthString);

https.endRequest();

This code works for several days without problems and server receives correct headers. After a while i am starting to get messed headers. This is the data i collect on the EndPoint if headers that are not correct:

23.9.2019. 23:48:36: Request headers: 23.9.2019. 23:48:36: Key: Authorization, Value: Basic aW90LnVzZXJ0ZXN0OiNJb1UyMDE4 23.9.2019. 23:48:36: Key: api-key, Value: 2019.09.23%2023:48:28

Observe "api-key" header, it received date and time from the device and not serial number from cfg.sn as it should .

did someone else observed this behaviour or maybe someone have some advice on how to avoid it. Currently i just reset arduino after 3 consecutive errors. Thanks in advance.

isosel commented 4 years ago

print cfg.sn on serial monitor to check if you send the right data when you detect the error.

maybe your endpoint modifies the serial number.

try to monitor your request with Wireshark to check if data send through the network are correct