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

Multiple SSLClient Instances with TinyGSM - "Arduino client is already connected" Error #105

Open
RuzgarErik opened this issue Nov 21, 2024 · 0 comments
Labels
question Further information is requested

Comments

@RuzgarErik
Copy link

I'm trying to set up multiple SSL connections using TinyGSM and SSLClient for an ESP32 project. One connection is for MQTT and another for HTTPS communication. However, when creating the second SSLClient instance, I'm getting the warning: "Arduino client is already connected? Continuing anyway sometimes.

// First client setup
TinyGsmClient clientGSM(modem, 1);  // First TinyGSM client
SSLClient net(clientGSM, TAs, (size_t)TAs_NUM, 3, 9);  // First SSL client for MQTT

// Second client setup - This causes the warning
TinyGsmClient client2GSM(modem, 2);  // Second TinyGSM client
SSLClient net2(client2GSM, TAs, (size_t)TAs_NUM, 3, 9);  // Second SSL client - generates warning

and using net2 like


bool SensorAPI::sendRequest(const char* endpoint, const JsonDocument& doc) {
    Serial.println("[Sensor API] Sendrequest invoked");
    String requestBody;
    serializeJson(doc, requestBody);

    String vorp = String("/api/embedded/") + String(endpoint);

    if(netINT.connect(serverName, 443)) {
        Serial.println("[Sensor API] Connected to server");
        netINT.println("POST " + vorp + " HTTP/1.1");
        netINT.println("Host: " + String(serverName));
        netINT.println("Content-Type: application/json");
        netINT.println("Content-Length: " + String(requestBody.length()));
        netINT.println("X-CSRFToken: " + String(csrfToken));
        netINT.println("Connection: close");
        netINT.println();
        netINT.println(requestBody);
        Serial.println("[Sensor API] Request sent");

        if(netINT.available()) {
            netINT.flush();
            netINT.clearWriteError();
        }

        return true;

    }
     else {
        Serial.println("[Sensor API] Connection failed");
        return false;
    }

return true;
}

@RuzgarErik RuzgarErik added the question Further information is requested label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant