Page 1 of 1

Does anybody managed to establish HTTP with server at port 8080?

Posted: Tue Feb 11, 2025 7:30 pm
by powerbroker
hi,

even if it works with default HTTP port 80, i cannot use it whith server on 8080: http.POST(...) returns -1.
doing this way:

Code: Select all

if(WiFi.status()== WL_CONNECTED){

    HTTPClient http = HTTPClient("192.168.102.23", 8080);

    String httpRequestData = "serial=1&temp=29";

    int httpResponseCode = http.POST("/MR-Prototype/app/data/values/add", "application/x-www-form-urlencoded", httpRequestData);
    
    if (httpResponseCode > 0){
      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);
      Serial.println("Response payload:");
      Serial.println(http.getString());
    } else {
      Serial.print("Error code: ");
      Serial.println(httpResponseCode);
    }
    
    http.end();
}
if i missed something?

Re: Does anybody managed to establish HTTP with server at port 8080?

Posted: Wed Feb 12, 2025 7:35 pm
by lbernstone
begin is a method which actively tries to connect to the destination port. It cannot be part of the object definition.

Code: Select all

    HTTPClient http;
    http.begin("192.168.102.23", 8080);

Re: Does anybody managed to establish HTTP with server at port 8080?

Posted: Thu Feb 13, 2025 5:48 pm
by powerbroker
lbernstone wrote:
Wed Feb 12, 2025 7:35 pm
begin is a method which actively tries to connect to the destination port. It cannot be part of the object definition.

Code: Select all

    HTTPClient http;
    http.begin("192.168.102.23", 8080);
finally it compiles and goes on with:

Code: Select all

	http.begin("http://192.168.102.23:8080/app/data");