forked from amcewen/HttpClient
-
Notifications
You must be signed in to change notification settings - Fork 170
Closed as not planned
Labels
type: supportOT: Request for help using the projectOT: Request for help using the project
Description
Issue
When making request to www.google.com, the request(GET) is OK, but, when make request to google.com, this returns an error!
I have an API in Heroku, that has the X URL, and when I access using the HttpClient, it's return error(-1)!
The same error occur when access google.com!
I think that is because some type of redirect or something else, but I can't confirm this!
Somebody know how to resolve this problem?
Example code
#define TINY_GSM_MODEM_SIM800
#include <SoftwareSerial.h>
#include <TinyGsmClient.h>
#include <ArduinoHttpClient.h>
// Defina os pinos RX e TX conectados ao SIM800L
#define MODEM_RX 19
#define MODEM_TX 18
// Substitua pelos detalhes da sua rede
const char apn[] = "claro.com.br";
// Objeto Serial para comunicação com o modem
SoftwareSerial SerialSIM(MODEM_RX, MODEM_TX);
// Inicializa o modem SIM800L
TinyGsm modem(SerialSIM);
TinyGsmClientSecure client(modem);
HttpClient http(client, "www.google.com", 443);
void setup() {
// Inicializa o Serial Monitor
Serial.begin(9600);
// Configura e inicia o Serial para comunicação com o modem
SerialSIM.begin(9600);
delay(3000); // Dê um tempo para o modem iniciar
http.setHttpResponseTimeout(30000);
// Reinicia e inicializa o modem
modem.restart();
Serial.println("Configurando APN...");
modem.gprsConnect(apn, "claro", "claro");
// Verifica se a conexão foi estabelecida
if (modem.isGprsConnected()) {
Serial.println("Conexão GPRS estabelecida");
} else {
Serial.println("Erro ao conectar GPRS. Verifique APN, usuário e senha.");
return;
}
modem.sendAT("+HTTPSSL=1");
}
void loop() {
// Faz uma requisição HTTP GET
Serial.println("Realizando requisição HTTP GET...");
int err = http.get("/");
// Verifica se a requisição foi bem-sucedida
if (err == 0) {
Serial.println("Iniciando recebimento da resposta...");
int status = http.responseStatusCode();
Serial.print("Código de status: ");
Serial.println(status);
String response = http.responseBody();
Serial.println("Corpo da resposta:");
Serial.println(response);
} else {
Serial.print("Falha na requisição: ");
Serial.println(err);
}
delay(10000);
}Metadata
Metadata
Assignees
Labels
type: supportOT: Request for help using the projectOT: Request for help using the project