由于http代码-1,无法通过http调用将数据发送到服务器

由于http代码-1,无法通过http调用将数据发送到服务器,http,https,arduino,esp32,esp8266wifi,Http,Https,Arduino,Esp32,Esp8266wifi,**我的esp32通过WIFI连接到互联网。我想通过https向服务器发送一些数据。但我随机得到了http返回码-1。当硬复位esp32时,其工作正常,响应为200。由于这个问题,我面临数据丢失。我不知道原因,甚至找不到任何解决办法。帮帮我** String DTurl=(String)BASE_URL+"getdevicedatanew"; String playload= "apidata="+code+"/"+PASSWORD+&

**我的esp32通过WIFI连接到互联网。我想通过https向服务器发送一些数据。但我随机得到了http返回码-1。当硬复位esp32时,其工作正常,响应为200。由于这个问题,我面临数据丢失。我不知道原因,甚至找不到任何解决办法。帮帮我**

String DTurl=(String)BASE_URL+"getdevicedatanew";
String playload= "apidata="+code+"/"+PASSWORD+"/"+(String)data;
if(WiFi.status() == WL_CONNECTED)
  {
    HTTPClient http;
    http.begin(DTurl);
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");
    http.setTimeout(45000);
    DEBUG_SERIAL.println("Sending data to server: "+ playload);
    int httpCode = http.POST(playload);
    DEBUG_SERIAL.println("httpcode:"+(String)httpCode);
    last_data_sent_time = millis();
    if(httpCode == HTTP_CODE_OK)
    {
      String response = http.getString();
      DEBUG_SERIAL.println("Http response success: "+ response);
      return true;
    }
   
    else
    {
      return false;
    }
    
  }
  else
  {
    return false;
  }
不要使用字符串类。