Can I access the database through http:// instead of https://

Dear manager, Can I access the database through http:// instead of https://. Because our devices use 2G GSM module, it doesn’t support security connection https://, but only support traditional http:// connection.
That means, our device can not POST data to “https://us1.unwiredlabs.com/v2/process.php”. Is “http://us1.unwiredlabs.com/v2/process.php” available?

We support both http and https

Please write to us at [email protected] for Unwired Labs support :smiley:

Thank you, Sagar.

Hi @Sagar, I am using an Arduino MKR GSM 1400 module for my thesis work to query your database which as you mentioned should be accessible from both HTTP and HTTP addresses. I tried to send the GET request to your website and faced the error 301 on port 80. So I changed the port to 443 but again faced another error “failed to connect to opencellid.org”. I shared my source code which has been written in Arduino C++ language.

Source code:

#include <ArduinoHttpClient.h>
#include <MKRGSM.h>

// Initialize GSM and GPRS modules
GSM gsmAccess;
GPRS gprs;
GSMClient client;

char server[] = "opencellid.org";
int port = 80; // Use HTTP port for non-secure requests

// Your OpenCellID API key and cell tower information
const char* apiKey = "pk.***********************************"; //  OpenCellID API key
const char* mcc = "244"; //  MCC
const char* mnc = "91"; //  MNC
const char* lac = "1337"; //  LAC
const char* cid = "23558"; //  CID

// GPRS credentials - APN details
const char apn[] = "internet"; // Your APN
const char login[] = ""; // APN username (if any)
const char password[] = ""; // APN password (if any)

void setup() {
  Serial.begin(9600);
  while (!Serial) {}

  // After starting the modem with GSM.begin()
  Serial.println("Connecting to GSM network...");
  if (gsmAccess.begin() != GSM_READY) {
    Serial.println("Failed to connect to GSM network");
    return;
  }

  Serial.println("Connecting to GPRS...");
  if (gprs.attachGPRS(apn, login, password) != GPRS_READY) {
    Serial.println("Failed to connect to GPRS");
    return;
  }

  HttpClient http(client, server, port);
  Serial.println("Fetching cell tower information...");

  // Construct the URL for the GET request
  String url = "/cell/get?key=" + String(apiKey) + "&mcc=" + String(mcc) + "&mnc=" + String(mnc) + "&lac=" + String(lac) + "&cellid=" + String(cid) + "&format=json";

  // Make a HTTP GET request to OpenCellID
  http.beginRequest();
  http.get(url);
  http.endRequest();

  // Read the status code and body of the response
  int statusCode = http.responseStatusCode();
  String response = http.responseBody();

  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);
}

void loop() {
  // Keep the program running
}

Output on port 80 :

Connecting to GSM network...
Connecting to GPRS...
Fetching cell tower information...
Status code: 301
Response:

Output on port 443 (HTTPS Request):

Connecting to GSM network...

Connecting to GPRS...

Fetching cell tower information...

Status code: 400

Response: <html>

<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>

<body>

<center><h1>400 Bad Request</h1></center>

<center>The plain HTTP request was sent to HTTPS port</center>

<hr><center>cloudflare</center>

</body>

</html>