Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HttpURLConnection timeout problem

Status
Not open for further replies.

stemy

Programmer
Aug 25, 2001
39
IL
Hi
I have a weird problem with HttpURLConnection.
I'm running a servlet on a tomcat server. When I access it from a web browser through or it works fine. the weird thing happens when I access it through an external client I wrote, that uses HttpURLConnection. I'm doing
Code:
HttpURLConnection conn = (HttpURLConnection) url.openConnection();[code] 
and if I'm using [URL unfurl="true"]http://localhost:8080/servletname[/URL] it works fine, but if I'm using [URL unfurl="true"]http://computername:8080/servletname[/URL] it throws an IOException with timeout error.
any suggestions?
 
I'm guessing here, but I imagine that Tomcat is smart enough to use the local DNS file (on windows it's the HOSTS file) to resolve the "computername" reference, but the httpURLConnection does not - there may be a default value for localhost that allows it to work.
 
thanks idarke, I suppose your guess was close enough. I simply added an entry to my HOSTS file:
127.0.0.1 computername
and it worked like a charm. Now that I think of it, I once told ZoneAlarm to lock my HOSTS file (as a defence against some viruses), and maybe that entry would've been added automatically if it wasn't for that protection.
anyway, thanx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top