Access web page using sockets - IP related error

Posted by oedev on 15-Jan-2015 02:42

Hello All,

We have some code which connects to a web page (weather feed) and parses the returned XML. This has worked for while, but is now returning an error rather than the xml contents we normally expect.

The error returned indicates the we are trying to access the page using a direct IP, which the host providers do not allow (cloudflare). But, we are not using an IP, rather the the full domain name.

The url looks like this (I've had to remove the user id and password, so will not work for you):

http://data.netweather.tv/feeds/webfeed2.pbx?datestart=2015011515;dateend=2015011815;locations=CT48HS;fields=maxtemp,mintemp,forecast,windspeed,winddirection,prec,soiltemp,soilmoisture,humidex,cloudcover,image,sunrise,sunset

If you try it with the IP address you'll see the "Direct IP access not allowed" error page, so the error is returned even before the API is hit.

http://104.20.19.79/feeds/webfeed2.pbx?datestart=2015011515;dateend=2015011815;locations=CT48HS;fields=maxtemp,mintemp,forecast,windspeed,winddirection,prec,soiltemp,soilmoisture,humidex,cloudcover,image,sunrise,sunset

Using the example code provided in the link below I get the same error, i.e. even though I use data.netweather.tv in the URL.

http://knowledgebase.progress.com/articles/Article/20011

My guess is that netweather have changed hosting providers, and therefore I'm getting this error. But, the question is that why is progress translating my request to use an IP and is this something that can be overridden ?

Thanks!

Posted by Marian Edu on 15-Jan-2015 03:25

Guess what you're missing is simply setting the 'Host' HTTP header on request... progress will not translate your request as you're the one that builds the request, the name resolution will do it's work and socket connect will get a valid IP address but that is normal and certainly not the issue.

All Replies

Posted by Marian Edu on 15-Jan-2015 03:25

Guess what you're missing is simply setting the 'Host' HTTP header on request... progress will not translate your request as you're the one that builds the request, the name resolution will do it's work and socket connect will get a valid IP address but that is normal and certainly not the issue.

Posted by oedev on 15-Jan-2015 03:29

Thanks, that does the trick!

Cheers.

This thread is closed