can not use http.begin() in HTTPClient Arduino Library to open my IP

3.4k Views Asked by At

i have an esp32 cam with 192.168.1.54:8082 IP. i want use from http.begin ("http://192.168.1.54:8082"); in HTTPClient Arduino Library that not working while when i am using "http://192.168.1.54:8082" in a browser working fine. any help can be useful.

#include <HTTPClient.h> 

HTTPClient http; 

http.begin("192.168.1.54:8082"); //Not Working Here (but in a browser 192.168.1.54:8082 works fine) 
int httpCode = http.GET(); 
if (httpCode > 0) { 
  String payload = http.getString(); 
  Serial.println(httpCode); 
  Serial.println(payload); 
} 
else { 
  Serial.println("Error on HTTP request"); 
} 
http.end();
1

There are 1 best solutions below

3
hcheung On

The API for http.begin(url) assumed standard port of 80 or 443 is used. In order to use port 8082, you need to pass in the port as function argument like this:

http.begin("192.168.1.54", 8082);