0

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]
2
  • 2
    what does the response code 404 mean? Commented May 11, 2018 at 0:58
  • An html page with saying "page not found" Commented May 11, 2018 at 10:50

1 Answer 1

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: Fri, 11 May 2018 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: Wed, 11 Jan 1984 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>
1
  • Thank you so much! I solved it using these headers with HTTP/1.1 Commented May 13, 2018 at 14:17

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.