I've tried a variety of approaches using code similar to this
WiFiClient Client;
HTTPClient Http;
int ResponseCode;
String Url, ReqBody, ResponseStr;
Url = "http://192.168.x.xxx:8080";
ReqBody = "Action=Ping";
Http.begin(Client, Url.c_str());
/* Also tested
Http.begin(Url.c_str());
Http.begin(Url);
Http.begin(Client, Url, Port); //i.e. separating the port from the URL
*/
Http.addHeader("Content-Type", "application/x-www-form-urlencoded");
ResponseCode = Http.POST(ReqBody);
/* Also tested
ResponseCode = Http.GET();
ResponseCode = Http.PUT(ReqBody);
*/
ResponseStr = Http.getString();
Serial.println("ResponseCode: " + String(ResponseCode));
Serial.println("ResponseStr: " + ResponseStr);
Http.end();
The result is always either response code 400 or -1
The server at the above LAN address is Node.js designed for this kind of testing.
- It responds to all requests using any method GET, POST, PUT, DELETE, etc.
- It responds to any request header, body, any path -- really everything
Yet that Node server gives no indication of having received anything when the above code is run from an ESP32.
The ESP32 is confirmed connected to the same LAN