• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2064
  • Last Modified:

Socket Error. No route to host.

Hi.

I'm using Indy to parse a page.
I never had a problem when i compile and execute my application to my pc.
But when i try to run it on any other computer 90% of the times i get errors like :
Error 10065 "No route to host"  >> A socket operation was attempted to an unreachable host.

No problem when i open the page in FireFox or Explorer...

Whats wrong ?
0
CodedK
Asked:
CodedK
  • 5
  • 5
1 Solution
 
2266180Commented:
I would assume there are some problems with your code. what do you use as host? can you show me a piece of code plus an actual example of a hsot and url and whatever needed, that fails with that error?
0
 
CodedKAuthor Commented:
Hi Ciuly.

Sorry for the delay. I was at work.

Here's a piece of the code :
  Feed := TStringList.Create;
  idHttp1:=TIdHTTP.Create(self);
  idHTTP1.Request.UserAgent:='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3';
  idHTTP1.HandleRedirects:=True;
  Site:='http://www.somesite.com';
  Feed.Text := idHttp1.Get(Site);
  Feed.Text :=AdjustLineBreaks(Feed.Text, tlbsCRLF);
  idHttp1.Free;

For host i dont use anything.
0
 
2266180Commented:
ok. so the issue is with www.somesite.com since that is the host.
you say that this is happening with 90% of the sites. which means there are sites that work,
- so a firewall blocking the app is out of the question.
also, you say that the same site works on your computer but not on the other. which means that
- the server does not block by user agent
further more, on the same computer, the same site work from browser but not from your app, which means that
- the server does not block by IP

and still, you have problems. you realise that this is almost impossible with this data. you are not giving me some cruciual information.

but, there is one small possibility: open up a cmd window and run
ping -t www.somesite.com

then make sure you execute your application using the IP of the site and not the server name (because it may be that, like google and others, it will allocate a different IP ;) )
so change the line
Site:='http://www.somesite.com';
to
Site:='http://aaa.bbb.ccc.ddd'; <- IP here

now, if you get no route to host and teh cmd window shows that all pings reply correctly and in acceptable time (less than 100 ms), then there is something that is sneaky :)

let's rule out indy next. what version are you using? (full version, including minor and build)

PS: are you absolutely sure that the error happens with the mentioend code? isn't' there another place where you use sockets?

oh, and one more thing: is it
- hardocded Site:='http://www.somesite.com';
or
- loaded from a file
- somehow generated or parsed from somewhere?
because if it's not generated, you must put a breakpoint on that ine and make sure that the site is correct. you might have an error in some other palce of your application which incorrectly parses out the site and adds or removes some characters ;) (this should normally be a dns issue, but still, doesn't hurt making absolutely sure. if you can log it to file even better, since that gives you a better overall look)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CodedKAuthor Commented:
Hi Ciuly.
Thanks for your super complete answer :)
Well... to answer the questions above :

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1) The sites that i' m checking are only two (same server). It doesn't work on almost 50% [90% is an exaggeration :)]   of the computers i run it (for both sites)...The same time i can open from the browser the page i want. When i posted the question, i couldn't make it run from work
(no firewall, no nothing).

2) Indy Version 9.0.18

3) Absolutely positive... i don't use anywhere else sockets. (Just this code nothing more)

3) The data i parse is  generated from indy get ....At the begging i was saving the file. Now i keep it in this StringList. Parsing is excellent. It starts from another event on the form so the only code that creates the problem is the Indy code above. I keep the file i get inside a memo and i can crosscheck with the original. Its the same.

4) One of the computer i've run this app uses proxy settings in the browser. So i guess in this situation its normal not to open the page from my application (by the way what can i do about this?
is user input needed to give proxy info or can i get it automatically ?)...
Now the one that isn't normal is running the app from my laptop. Whenever it wants it runs most of the times it returns this error :/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
0
 
2266180Commented:
1) I thought it was p0% of the sites. so only 2 sites. can you do the ping test with both (open 2 cmd windows, one for each)?

3) I was talking about parsing out the sitename :)

4) that is correct., you'll need to set the proxy in indy as well via the dedicated properties. you can also get it automatically via IE api or registry. eg: http://www.delphifaq.com/faq/delphi/network/f239.shtml )
0
 
CodedKAuthor Commented:
I am at home now i cannot recreate the error...
I did ping the sites. Everything runs smoothly here. I can see this going nowhere :/
I will accept your last comment :)  Maybe it was a combination of proxy settings, bad network, bad timing... I will post a new question if have any more info.

But i want to make something clear in my head.
Can you please explain a little more why i should parse out the server name and replace it with the IP. I mean... why is this better ?
0
 
2266180Commented:
you miss-understood me. since I didn't know what you were doing, I tried to cover all bases. you might have a config file or whatever from where you read up those 2 site names. also, you mentioend they are on teh same server so I suspect they have the same IP address. in this case you won't be able to use the IP stuff since you the site names are different and the http server uses the reported site name to identify the virtual site.

anyway, the idea with the IP was in case the server was changing IP's. ping google a few times and you will notice you get different ip addresses almost every time. so if you server was using something like this, it could have happened that when your applicaiton tried to connect, it received an ip address that had a bad route and when trying from browser, you receiveid another ip address which was ok. that's why I was suggesting testing with IP addresses, to rule this out. but with your latest information, this is not the case.

I don't mind if you keep the quesiton open until you get to a place where you cen reproduce the issue. it can be because proxy settings. htough 50% of people using proxy is a little too much. nowadays people use NAT, which is transparent to the user and applications.

btw, you will need to do the proxy test on a PC you know the values of the proxy so you can check that indeed the code from the link I gave you returns correct info ;)
1
 
CodedKAuthor Commented:
Thanks Ciuly, i will try late at night if i get the chance or tomorrow. And post back :)
0
 
2266180Commented:
take your time
0
 
CodedKAuthor Commented:
By using the function to get proxy settings everything worked fine.
I hope its solved :)
Thank you Ciuly :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now