• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Connection timed out issue while accessing URL

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 Hi ,

     i am trying to connect the following URL using java code but Exception in thread "main" java.net.ConnectException: Connection timed out: connect is blocking the
     progress. I am able to access the URL from browser in the same machine. Attached Header information details with this post.

      http://www.omdbapi.com/?t=Pagal&i=tt3896198&apikey=6c3a2d45;
         
          My code is as below

             
Header.png
[Thumbnail for Header.png]
 
Saloon Keeper
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't reproduce the issue - accessing the URL works fine both on the browser and via that Java code, and returns the same JSON.
 
Sheriff
Posts: 28326
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's possible that Gautamaxa's browser is using a proxy server to connect to the internet. If that's the case then the Java code isn't using the proxy server and therefore can't connect to the internet at all.

If that's what is happening here, then if I'm not mistaken there are system properties which allow Java code to use a proxy server.
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are: http://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html#Proxies

You can also specify a proxy in the call to openConnection.
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic