govorox / SSLClient

SSLClient - generic secure client Arduino library using mbedtls
GNU General Public License v3.0
84 stars 39 forks source link

Firebase endpoint connection issues (help about proper firebase root cert?) #65

Closed ilgarbenli closed 9 months ago

ilgarbenli commented 9 months ago

Hello, I am trying to send data to firebase via sim800L. (LilyGo T-Call SIM800L_IP5306_VERSION_20190610)

It couldn't connect firebase endpoint. In code, hostname is "location-12dc8-default-rtdb.europe-west1.firebasedatabase.app" and port is 443.

Maybe I couldnt load proper root cert for firebase.

At the line 5, it returns false and prints "HTTPS error".

I am open any advice about connecting firebase.


1.  if (sim_modem.isGprsConnected())
2.   {
3.   Serial.println("");
4. 
5.     if (http_client.connect(hostname, port)) {
6. 
7.     Serial.println("Connected to API endpoint\n");
8.     Serial.println("making PUT request");
9.     http_client.beginRequest();
10.     String body = "{\"location\": {\"latitude\": 3,\"longitude\": 3}}";
11.     String request = "PUT " + String(resource) +" HTTP/1.1\r\n";
12.     request += "Host: " + String(hostname) + "\r\n";
13.     request += "Content-Type:application/json\r\n";
14.     request += "Content-Length:" + String(body.length()) + "\r\n";
15.     request += "Connection: keep-alive\r\n\r\n";
16.     request += body;
17.     http_client.println(request);
18.     http_client.endRequest();
19. 
20.     int status_code = http_client.responseStatusCode();
21.     String response = http_client.responseBody();
22. 
23.     Serial.print("Status code: ");
24.     Serial.println(status_code);
25.     Serial.print("Response: ");
26.     Serial.println(response);
27.     Serial.println("----------: ");
28.    Serial.println(body);
29.     http_client.stop();
30. 
31.     } else {
32.          Serial.println("HTTPS error\n");
33.     }
34.   }
35.   else
36.   {
37.     Serial.println("...not connected");
38.   }
ilgarbenli commented 9 months ago

I solved with https://github.com/Samorange1/Connect-ESP32-to-Firebase-via-GSM .