HttpExampleClient
Answer
9/7/18 5:41 AM

Hello Everyone,

I am testing the HttpExampleClient example.

I have some error to use the Post function.

I use the localhost Webserver to teste. Could you advice how to do?

 

0 (0 Votes)
RE: HttpExampleClient
Answer
9/7/18 1:27 PM as a reply to Choi Goeun.
Hello Choi,

The error you are getting is pointing to the error RC_HTTP_SEND_ERROR , which indicates that the HTTP request cannot be sent out.

This can have multiple reasons. One of them would be that your XDK is not connected to your local Wi-Fi network. The other one would be that your HTTP server is not reachable.

I assume that here applies the second reason, that your HTTP server is not reachable. In that regard could you please provide the outline where you configure the server address and the port where the XDK should send data to?

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: HttpExampleClient
Answer
9/17/18 3:21 AM as a reply to Franjo Stjepandic.

Hello Franjo,

I test the two type of web server again.

 

1) Localhost web server : localhost:3000

2) hosting web server : http://goeun.herokuapp.com/

 

But, I have some both of same error

11[PIP:2] error in Get host IP by name -172

 

Could you advice error?

0 (0 Votes)
RE: HttpExampleClient
Answer
9/17/18 1:11 PM as a reply to Choi Goeun.
Hello Choi,

Thank you for providing further information on your issue.

The error you are getting is simply stating, that the DNS request performed by the XDK to resolve the IP address from the domain name is failing.

In regards to your first own notebook as HTTP server, you configured in the field DEST_SERVER_HOST the destination IP address with an additional / . This backslash is an indication for a URI and should be removed because it might be the cause, why the underlying DNS request is failing.

In regards to your other web server, I am, unfortunately, also not able to reach it and this might be the fact why the DNS request is failing as well. Am I right, that this is an internal website, not reachable over the internet? If that is correct, then this might be the cause, why the XDK is here unable to get a successful DNS response with a corresponding IP address.

On that behalf, it would be helpful if you could try to ping http://goeun.herokuapp.com/   to see if you get with your notebook a response from the webpage.

Otherwise, have you tried a different web server as postman-echo.com or httpbin.org out as well?

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: HttpExampleClient
Answer
9/18/18 1:29 AM as a reply to Franjo Stjepandic.

Hello,

Thanks so much you replying.

 

1) Regrading the my localhost web server,

I added the destination IP address with an additional / . but it is failed.

Is it possible to request the local web server?

 

2) Thanks so much you guide web server as postman-echo.com.

I could test the postman-echo.com. but it has the same error.

Could you advice please?TT

 

 

0 (0 Votes)
RE: HttpExampleClient
Answer
9/18/18 3:06 PM as a reply to Choi Goeun.
Hello Choi,

I am always glad to help.
Most likely, the error seems to be caused by the additional path (URI) you inserted in the URL:
 
  • The written /, when trying to use your own server
  • The additional /get, when using postman-echo.com
Further, for these informations, the fields DEST_GET_PATH and DEST_POST_PATH are prepared in the HttpExampleClient example.

In regards to your own server, using localhost as destination URL will not work.
This is used to access the hosts, in your case your own notebooks/pcs, running network services by bypassing any local network interfaces.
To establish a successful connection via HTTP to the XDK, you need to insert the correct IP address of your own notebook/pc.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: HttpExampleClient
Answer
9/19/18 11:23 AM as a reply to Franjo Stjepandic.

Hello Franjo,

Thank you :-)

 

1) Regarding the localhost server,

I tried the the "ipadress:3000"

Is it right to wrote "ipadress/3000"?

 

2) Regarding the postman-echo

you mean that, Is it right the below vlaue?

DEST_SERVER_HOST  "http://postman-echo.com"

DEST_POST_PATH "/get"

0 (0 Votes)
RE: HttpExampleClient
Answer
9/20/18 7:41 AM as a reply to Choi Goeun.
Hello Choi,

This looks way better.

To come to your points:
 
  1. The #define DEST_SERVER_HOST "192.168.0.11:3000" is absolutely correct and should work XDK sided.
    The linked port behind the ip address, in your case port 3000, requires the character : right before the port number itself, to announce the port, instead of this character /, which would expand a path.
    If this does not work, the issue locates probably within the DNS configuration of your Wi-Fi network.
    In this case, open your router's Wi-Fi settings and edit your DNS configuration to allow the XDK to communicate.
     
  2. Your provided code lines, regarding the postman echo look fine, too.
    Keep in mind, a DEST_POST_PATH path like in your latest screenshot is not required for the execution of DNA requests.
Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: HttpExampleClient
Answer
9/27/18 8:11 AM as a reply to Franjo Stjepandic.

Hello,

Thanks to you, I could sucess the connection.

BTW, I have another error.

"Failed HttpCient_initRequest"

"error occured in connecting server"

Could you advice to me?

And I have one more question.

varial uint8_t payload[] is send to the server?(XDK->PC)

0 (0 Votes)
RE: HttpExampleClient
Answer
9/27/18 2:16 PM as a reply to Choi Goeun.
Hello Choi,

I am glad to read about your successful progress on your project.

In regards to your other error, could you please tell me in which XDK-Workbench you are currently implementing your XDK application? As far as I can observe you are not using the HttpExampleClient example from the XDK-Workbench 3.3.1 and 3.4.0.
The new XDK-Workbench 3.4.0 comes with great improvements, maybe you want to try it out.

On the first glance, I assume that you need to check the return values of the function HttpClient_initRequest() , to narrow the error down.

Yes, you are correct, the variable payload is the data which is to send within the POST request to the HTTP server.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: HttpExampleClient
Answer
10/1/18 11:29 AM as a reply to Franjo Stjepandic.

 Hello,

 I download the 3.4 Workbench and then I tired.

 Could I ask more question?

 I want to send the data like that. I think it is the POST function(client->server). not GET function.

 Q1) As my understanding, is it right? 

 Q2) What is it the POST_REQUEST_BODY?

 #define POST_REQUEST_BODY               "{ \"device\": \"XDK110\", \"ping\": \"pong\" }"

 Q3) when I want to data to the server, Is it right to use the httpMessage variable? 

0 (0 Votes)
RE: HttpExampleClient
Answer
10/1/18 2:59 PM as a reply to Choi Goeun.
Hello Choi,

I am glad to hear that you upgraded your XDK-Workbench to the latest XDK-Workbench 3.4.0.

Additionally, you can, of course, ask further questions, that is what the XDK community is for.

Yes, you are correct. If you want to send sensor values via HTTP to a server, you need to use the POST request, instead of the GET request.

The define POST_REQUEST_BODY , which gets declared within the header file AppController.h , contains in this example the static payload for the POST request itself.

Furthermore, the POST_REQUEST_BODY variable is passed as payload into the struct HTTPRestClientPostInfo , which is send over the function HTTPRestClient_Post() .

In regards to the variable HttpMessage , this variable is included in the function HTTPRestClientPostInfo , which contains a bit more than just the payload.

It is used to transmit the whole data package, including the header and the payload, which stores your message to post.

Nevertheless, you do not need to make any modifications within the function HTTPRestClient_Post() .

To fit this to your needs, you could write your sensor values or the message you want to transmit into the payload element of the struct HTTPRestClientPostInfo and then call the function HTTPRestClient_Post() , after reading the sensors, to send them.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)