Can't send HTTP GET for my custom server with connection failed message

Hi, I just built a very small server on the digitalocean, and use Spark core to send a HTTP GET request every few seconds,

in my browser test, the HTTP GET request goes successfully with data returned, however, when the Spark sent the HTTP request, only received the message in the serial screen like:
Httpclient: Connection failed, Application status: -1

This is my testing web url:, so you can see it works.

Hi @helxsz,
When you share a code snipped we can look in to it :wink:

In particular, how are you passing the IP address of your host?

You cannot do "" since DNS won’t resolve that.

You can do IPAddress(178,62,14,49)

1 Like

Hi,@bko, I think this might be the problem. This is my code.

I look at the http_request structure,

typedef struct
String hostname;
IPAddress ip;
String path;
//int port = 80;
int port;
String body;
} http_request_t;

so i did this showed as below

    request.IPAddress = IPAddress(178,62,14,49);
    request.port = 8080;
    request.path = "/";
    http.get(request, response, headers);

I got a error saying
the_user_app.cpp:79:17: error: ‘struct http_request_t’ has no member named ‘IPAddress’

Do you have any code snippet to make it clear for me please?

Hi @helxsz

I think you need to do this:

request.hostname = NULL;
request.ip = IPAddress(178,62,14,49);
request.path = "/";
http.get(request, response, headers);

oh, thanks, @bko