Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
How to access https protected API from ESP8266?

I'll repost all my question because I descovered the problem is the SSL access as pointed by a user here. So I already don't received more 308 message, but my ESP8266 crashes wen I try to access any "https" website.

I'm using this code to try to access:


const char* endpoint = "https://hvilela.com:443/api/data/all";

void onClientStateChange(void* arguments,
                         asyncHTTPrequest* aReq,
                         int readyState) {
  Serial.println(readyState);
  switch (readyState) {
    case 0:
      // readyStateUnsent     // Client created, open not yet called
      break;

    case 1:
      // readyStateOpened     // open() has been called, connected
      break;

    case 2:
      // readyStateHdrsRecvd  // send() called, response headers available
      break;

    case 3:
      // readyStateLoading    // receiving, partial data available
      break;

    case 4:
      // readyStateDone       // Request complete, all data available.

#ifdef SERIAL_DEBUG
      Serial.println(aReq->responseHTTPcode());
#endif
      if (aReq->responseHTTPcode() != 200) {
#ifdef SERIAL_DEBUG
        Serial.println("return");
#endif
        return;
      }
      String response = aReq->responseText();
#ifdef SERIAL_DEBUG
      Serial.println(response.c_str());
#endif
      break;
  }
}

void setupClient() {
  
  String URL2 =  endpoint; 

  client2.setTimeout(5);
  client2.setDebug(true);
  client2.onReadyStateChange(onClientStateChange);

  client2.open("GET", URL2.c_str());
  client2.send();

  delay(1000);
  Serial.println("[Client setup end]");
}

by accessing this endpoint, I need to receive a 410 Unauthorized message. Works perfectly in web browsers, but not in ESP8266.

Additionally, I'm using PlatformIO VSCode plugin to program.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The answer of @gre_gor was the key to discover the real problem.

I got the BasicHttps example and started to work, but not completely worked.

I though about a Vercel server problem, but finally, what explained the redirects too, was a 'google-domains' related problem I was having.

hvilela.com is a name on google domains, but inside Vercel this goes to another page (although I don't know why this page was not the Location in 308 advice), and only in this 'inside Vercel' page I could access the API correctly.

Hope this can help who have same problems in future

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda