Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Make HTTPS Requests - Connection Refused with Framework #69

Closed
besanur opened this issue Dec 30, 2024 · 2 comments
Closed

Unable to Make HTTPS Requests - Connection Refused with Framework #69

besanur opened this issue Dec 30, 2024 · 2 comments

Comments

@besanur
Copy link

besanur commented Dec 30, 2024

Hello,

I am experiencing an issue where I am unable to make HTTPS requests to a server when using this framework.

I have tested the same HTTPS request code in a separate, minimal project without the framework, and it works as expected. In both cases, I used the same root certificate for SSL/TLS verification.

However, when using the framework, the request consistently fails with the error: "connection refused".

This suggests that the issue may be related to how the framework handles networking or SSL connections.

Steps to Reproduce:

  1. Use the framework and attempt to make an HTTPS request with a valid root certificate.
  2. Observe the "connection refused" error.
  3. Run the same code in a standalone project without the framework.
  4. Observe that the request works as expected.

Expected Behavior:
The HTTPS request should succeed when using the framework, just as it does in the standalone project.

Actual Behavior:
The HTTPS request fails with a "connection refused" error when using the framework.

Environment:

  • Framework version: latest
  • ESP32 Board: lolin_s2_mini

If there are any specific configurations or dependencies required for the framework to handle HTTPS requests correctly, please let me know. I am happy to provide more details or debug further if needed.

Thank you for your support!

void requestData() {
  HTTPClient httpClient;
  WiFiClientSecure *client = new WiFiClientSecure;

  client->setCACert(test_root_ca);

  String url = API_URL + String(11027);
  Serial.print("Requesting data from server: ");
  Serial.println(url);

  // Führe HTTP GET-Request aus
  if (httpClient.begin(*client, url)) {
    Serial.print("Requesting data for ");

    int httpResponseCode = httpClient.GET();

    if (httpResponseCode == HTTP_CODE_OK) {
      Serial.println("data successfuly fetched");

      String payload = httpClient.getString();
      JsonDocument doc; 
      DeserializationError error = deserializeJson(doc, payload);

      if (error) {
        Serial.println("Failed to parse JSON");
      } else {
        Serial.println("Successfully stored data");
      }
      doc.clear();
    } else {
      Serial.printf("Failure during HTTP-GET. HTTP-Statuscode: %d", httpResponseCode);
      Serial.println();
      Serial.printf("Fehler: %s\n", httpClient.errorToString(httpResponseCode).c_str());
    }
  }
}
@theelims
Copy link
Owner

It should work. At least it uses WiFiClientSecure for the OTA feature to download the binary from Github. I need to look deeper into it.

@besanur
Copy link
Author

besanur commented Jan 1, 2025

It should work. At least it uses WiFiClientSecure for the OTA feature to download the binary from Github. I need to look deeper into it.

I found the problem. My wemos s2 mini does not have enough memory. The device causes me too many problems 😅.I don't have that with an esp32s3 supermini 💪

@besanur besanur closed this as completed Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants