2

I'm using the ESP8266 wifi module to send/receive packets on the web from my microcontroller. In particular I've been using the

AT+CIPSTART="TCP",'xxx.xxx.xxx.xxx,80\r\n

command to pick which endpoint I'm sending packets to. It currently works with static IPs (or domains with static IPs); but I have yet to find a resource saying how this could work with virtual IPs (or domains with virtual IPs).

I have websites hosted on shared servers, but every-time I execute this CIPSTART command (with IP or domain), the response is of the generic shared server IP address page.

How can I get my ESP8266 to connect with my specific site that is hosted on a shared server with a virtual address?

Resources I've read:

2
  • By "virtual IP" do you mean dynamic IP which changes over time or a virtual host where there is a single static IP, but hosts multiple websites on different domains? Commented Oct 3, 2015 at 20:20
  • Virtual host with single static IP and hosts multiple domains. Commented Oct 5, 2015 at 8:44

2 Answers 2

1

You should be able to use the domain name, as the DNS will automatically resolve the IPs for you. Be careful about the length value. You should add at least 4 characters to the actual length of the GET string to account for the carriage return / new line feeds:

AT+CIPSTART="TCP","api.thingspeak.com",80   
AT+CIPSEND=80
GET http://api.thingspeak.com/update?key=PBG7CKSZU6FU3M4C&field1=5 HTTP/1.0
Sign up to request clarification or add additional context in comments.

Comments

0

To connect to a virtual host, you connect normally to its IP and port with AT+CIPSTART.

AT+CIPSTART="TCP","xxx.xxx.xxx.xxx",80\r\n

The important part is when you send the HTTP request with AT+CIPSEND.
For the web server to distinguish between different virtual hosts, you need to add a Host HTTP header into the request.

GET /request.php?key=value HTTP/1.1\r\n
Host: www.example.com\r\n
\r\n

With this, the web server should return from the right host and not the default one, from the host provider.

2 Comments

I don't see how this connects to ESP8266. I've already tried using domain-names with the AT+CIPSTART and the http response is the generic one served from the shared IP address, not the one from the specific domain.
@DevonBernard I edited the answer to make it clearer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.