vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.91k stars 709 forks source link

Sending Post request empty body but correct content lenght #646

Open KnusperKnusper opened 2 years ago

KnusperKnusper commented 2 years ago

[x] I have read the Troubleshooting section of the ReadMe

What type of issues is this?

[ ] Request to support a new module

[ ] Bug or problem compiling the library [ X ] Bug or issue with library functionality (ie, sending data over TCP/IP) [ X] Question or request for help

What are you working with?

Modem: SIM800L Main processor board: Arduino DUE TinyGSM version: latest (0.11.5) Code:

Serial.print("Connecting to ");
  Serial.println(server);
  if (!client.connect(server, port)) {
    Serial.println(" fail");
    delay(10000);
    return;
  }
  Serial.println(" success");

  msg = "{"UL1":0.027327521,"UL2":0.118873939,"UL3":0.13162981}";
  if (client.connect(server,port)) {
  Serial.println("connected");
  client.println("POST /debug HTTP/1.1");
  client.println("Host: MYIPADRESS");
  client.println("Content-Type: text/plain;"); //application/json
  client.print("Content-Length: ");
  client.println(msg.length());
  client.println();
  client.println(msg);

  uint32_t timeout = millis();
  while (client.connected() && millis() - timeout < 10000L) {
    // Print available data
    while (client.available()) {
      char c = client.read();
      Serial.print(c);
      timeout = millis();
    }
  }
 }
}

Scenario, steps to reproduce

I try to post a Json String to a server. The body is empty but the content length is recognized correct.

Expected result

Receive the messagebody on my server

Actual result

empty body but correct content lenght

Debug and AT command log

23:05:09.729 -> Modem connecting to Server: OK 23:05:16.014 -> Connecting to MYIPADRESS 23:05:16.455 -> success 23:05:16.923 -> connected 23:05:18.168 -> HTTP/1.1 200 OK 23:05:18.168 -> X-Powered-By: Express 23:05:18.168 -> Access-Control-Allow-Origin: * 23:05:18.275 -> Content-Type: text/html; charset=utf-8 23:05:18.318 -> Content-Length: 4 23:05:18.456 -> ETag: W/"4-MByqNJgqvz3ZpGITR5RzlLTEsBo" 23:05:18.490 -> Date: Sun, 06 Mar 2022 22:05:17 GMT 23:05:18.591 -> Connection: keep-alive 23:05:18.591 ->