GET to ASP - new to Arduino

Firstly, I'm new to Arduino stuff so I'm rather at sea here - sorry!

I've successfully built this project and have it working with ThingSpeak - no problem.

However, I'd quite like to have the data come to a website of my own and I mistakenly thought it would be simple; just replace the ThingSpeak IP address with my own domain name.

I've written a simple ASP page that grabs the temperature and humidity numbers from a URL and adds them to a database - again, working perfectly via a browser.

So... should changing the IP in line 21 of the sample code to something like www.mydomain.com work, do you think, or does it really need an IP address?

Once again, apologies!

So... should changing the IP in line 21 of the sample code to something like www.mydomain.com work, do you think, or does it really need an IP address?

Something needs to convert the domain name to an IP address. Usually, there is a DNS (Domain name service) running somewhere that can do that. The initialization of the server instance takes the IP address of the DNS server as one of the optional arguments.

If you supply a DNS server IP address, you can use domain names instead of IP addresses. If you don't, you can't.

Ahhhh! That makes some sort of sense to me.

You couldn't you possibly suggest what I might add to the code to add the DNS? (I'm assuming I could just use something like Google's 8.8.8.8?)

I'm assuming I could just use something like Google's 8.8.8.8?

You could test that. No need to assume anything. Facts are better than assumptions, any day.

So... should changing the IP in line 21 of the sample code to something like www.mydomain.com work, do you think, or does it really need an IP address?

Yes, it has to be an IP address, the module does no name lookups.

BTW, the linked code is horrible, it might work with ThingSpeak but it's not a real HTTP request and it won't work with virtual servers (no Host: header).

Yes, I was beginning to think that it might be rather poor code. So adding a DNS server isn't as simple as adding a line or two of code?

Yes, I was beginning to think that it might be rather poor code. So adding a DNS server isn't as simple as adding a line or two of code?

At least it doesn't look like. Why don't you do the DNS lookup on your PC and fill in the correct IP?

Why don't you do the DNS lookup on your PC and fill in the correct IP?

Most likely because the domain won't always resolve to the same IP address. DNS handles ISPs changing IP addresses, within some reasonable time after the IP address changes, as long as the ISP registers the changed IP address. The ISP won't register a changed IP address if it doesn't know that a user is hosting a web site, unless that is part of the agreement with the ISP.

@PaulS: I know how the internet works. At least in my area ISPs very seldom change IP addresses of hosted sites. Completely different is the approach of hosting the site on a connection where hosting is not expected by the ISP, so it'll provide a dynamic IP. But there the ISP won't register the IP in it's DNS but the subscriber will have to update it using some DynDNS protocol.
In most cases where the site is hosted by the ISP the IP does change extremely seldom.

At least in my area ISPs very seldom change IP addresses of hosted sites.

I was thinking about people that have comcast as an ISP, for instance, who want to connect an Arduino to the router, and access it from the internet.

Comcast does frequently change the IP that it assigns to my router. When I make a GET request, the IP address of the router is part of the packet, so that the server can respond.

If comcast changes my router's IP address between the time I make the GET request and the time the server delivers the response, I won't get it.

If I check my router's IP address today, and use that, after setting up port forwarding, to access my Arduino-as-server, that same address will not work next week.

On the other hand, I have a domain, hosted by a different ISP. That domain's IP address has not changed since they started hosting the domain.

I just don't want OP to think that he/she can set up an Arduino-as-server, after enabling port forwarding on the router, get the current IP address of the router, and publish that as the "here's the address of a really cool Arduino-based server" address, and have the Arduino always have that IP address.

I’m not trying to get the Arduino to act as a server, I just want it to connect to a URL and pass a couple of values so I can grab them with a Request.QueryString.

nadampski:
I'm not trying to get the Arduino to act as a server, I just want it to connect to a URL and pass a couple of values so I can grab them with a Request.QueryString.

We understood that but where is your server? Does it have a fixed IP address? If yes, why don't you simply provide that in your sketch?

It's cloud-hosted so doesn't have a unique IP address, unfortunately.

There are online services that will do the domain name lookup, and return the IP address. Google dyndns (dynamic domain name service) or look at noip.com.

Thank you!