I'm using Arduino Uno and ESP8266 in a project.
I'm using AT Commands to connect to wi-fi and make a request. I'm using the monitor serial to test the code before compile it in arduino.
It is connecting to wi-fi and I can make a request to a server in my network but when i try to make a request to my web-service in cloud it doesn't work well.
The return is an HTML with an 404 page instead of what I am expecting:
<h1>Hello Versa</h1>
Here is my code:
AT+CIPSTART="TCP","ternary.com.br",80
AT+CIPSEND=18
GET /webservice/
Can someone help me telling me what I am doing wrong?
After see the answer of Maximilian Gerhardt, I solved it writing the following sequence in the monitor serialize:
AT+CIPSTART="TCP","ternary.com.br",80
AT+CIPSEND=70
GET /webservice/ HTTP/1.1
Host: ternary.com.br
Connection: Close
[Just press enter and send a new line]
-
2what does the response code 404 mean?jsotola– jsotola2018年05月11日 00:58:47 +00:00Commented May 11, 2018 at 0:58
-
An html page with saying "page not found"Ricardo Godoz– Ricardo Godoz2018年05月11日 10:50:33 +00:00Commented May 11, 2018 at 10:50
1 Answer 1
A HTTP requests is comprised of more than just GET /webservice/
. Take a look at what curl
(console-line HTTP client) does.
C:\>curl -v "http://ternary.com.br/webservice/"
* Trying 187.84.237.200...
* Connected to ternary.com.br (187.84.237.200) port 80 (#0)
> GET /webservice/ HTTP/1.1
> Host: ternary.com.br
> User-Agent: curl/7.46.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: 2018年5月11日 15:04:16 GMT
< Server: Apache
< X-Powered-By: PHP/5.6.30
< Vary: Accept-Encoding
< Cache-Control: max-age=0, no-cache, no-store, must-revalidate
< Expires: 1984年1月11日 05:00:00 GMT
< X-UA-Compatible: IE=Edge,chrome=1
< Pragma: no-cache
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
<h1>Hello Versa</h1>* Connection #0 to host ternary.com.br left intact
You will have to at least transfer the minimal correct HTTP Headers of the form
GET /webservice/ HTTP/1.1
Host: ternary.com.br
Connection: Close
To get an answer. Also mind the ending \r\n\r\n
. Refer to this website for more headers.
When I only send GET /webservice/
I also get 404 page.
C:\>cat test
GET /webservice/
C:\>cat test | ncat ternary.com.br 80
[...]
<title data-i18n="[html]404_page.title">404 ÔÇô P├ígina n├úo encontrada</title>
-
Thank you so much! I solved it using these headers with HTTP/1.1Ricardo Godoz– Ricardo Godoz2018年05月13日 14:17:20 +00:00Commented May 13, 2018 at 14:17