helxsz
April 13, 2015, 5:15pm
1
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: http://178.62.14.49:8080/ , so you can see it works.
marcus
April 13, 2015, 6:19pm
2
Hi @helxsz ,
When you share a code snipped we can look in to it
bko
April 13, 2015, 6:33pm
3
In particular, how are you passing the IP address of your host?
You cannot do "178.62.14.49"
since DNS won’t resolve that.
You can do IPAddress(178,62,14,49)
1 Like
helxsz
April 14, 2015, 1:02pm
4
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?
bko
April 14, 2015, 1:16pm
5
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);
2 Likes