Link to home
Create AccountLog in
Delphi

Delphi

--

Questions

--

Followers

Top Experts

Avatar of CodedK
CodedK🇬🇷

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 ?

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of 22661802266180🇺🇸

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?

Avatar of CodedKCodedK🇬🇷

ASKER

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.

Avatar of 22661802266180🇺🇸

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)

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of CodedKCodedK🇬🇷

ASKER

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 :/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Avatar of 22661802266180🇺🇸

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 )

Avatar of CodedKCodedK🇬🇷

ASKER

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 ?

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of 22661802266180🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of CodedKCodedK🇬🇷

ASKER

Thanks Ciuly, i will try late at night if i get the chance or tomorrow. And post back :)

Avatar of 22661802266180🇺🇸

take your time

Avatar of CodedKCodedK🇬🇷

ASKER

By using the function to get proxy settings everything worked fine.
I hope its solved :)
Thank you Ciuly :)

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

Delphi

Delphi

--

Questions

--

Followers

Top Experts

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Developmentâ„¢. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.