Electron slow http requests

electron
Tags: #<Tag:0x00007fe2262ba358>

#1

I am using HttpClient library and getting very slow request from test time server “http://worldtimeapi.org/api/ip” that takes less than 200ms from web browser.
This only hapens with electron, with photon over wifi there is everything ok.
I have good 3G signal with particle electron.

This is test code I am using…

#include "application.h"
#include "HttpClient.h"

/**
* Declaring the variables.
*/
unsigned int nextTime = 0;    // Next time to contact the server
HttpClient http;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
    //  { "Content-Type", "application/json" },
    //  { "Accept" , "application/json" },
    { "Accept" , "*/*"},
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

http_request_t request;
http_response_t response;

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

void loop() {
    if (nextTime > millis()) {
        return;
    }

    Serial.println();
    Serial.println("Application>\tStart of Loop.");
    // Request path and body can be set at runtime or at setup.
    request.hostname = "worldtimeapi.org";
    request.port = 80;
    request.path = "/api/ip";

    // The library also supports sending a body with your request:
    //request.body = "{\"key\":\"value\"}";
    
    int timeStart=millis();

    // Get request
    http.get(request, response, headers);
    
    int totaltime= millis()-timeStart;
    Serial.print("Application>\tTime for request: ");
    Serial.println(totaltime);
    
    Serial.print("Application>\tResponse status: ");
    Serial.println(response.status);

    Serial.print("Application>\tHTTP Response Body: ");
    Serial.println(response.body);

    nextTime = millis() + 10000;
}

I am getting response time from 5000-7500ms !!!??
If somene has reason/solution how to get faster response time please give me some advice.

EDIT

I am using this lib

I logged time for request, and rx transaction…
Http Request time it takes about 5- 6sec !!?
Receiving TCP transaction is from 1-2 sec.


Faster HTTP request