Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

I use the code from Sun's java tutorial

import java.net.*; import java.io.*; public class URLConnectionReader { public static void main(String[] args) throws Exception { URL yahoo = new URL("http://www.yahoo.com/"); URLConnection yc = yahoo.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } } 

Stack trace is same as Connection timed out. Why?Connection timed out. Why?

I suspect that might be problem with firewall but

  1. ping to google.com is okay
  2. it works in browser
  3. this approach fails for every URL I provide
  4. I use DJ WebBrowser component in other program and it works okay as a browser

How can I investigate more about this problem? Can I get to know which port numbers are going to be used when I run the code?

Thanks

I use the code from Sun's java tutorial

import java.net.*; import java.io.*; public class URLConnectionReader { public static void main(String[] args) throws Exception { URL yahoo = new URL("http://www.yahoo.com/"); URLConnection yc = yahoo.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } } 

Stack trace is same as Connection timed out. Why?

I suspect that might be problem with firewall but

  1. ping to google.com is okay
  2. it works in browser
  3. this approach fails for every URL I provide
  4. I use DJ WebBrowser component in other program and it works okay as a browser

How can I investigate more about this problem? Can I get to know which port numbers are going to be used when I run the code?

Thanks

I use the code from Sun's java tutorial

import java.net.*; import java.io.*; public class URLConnectionReader { public static void main(String[] args) throws Exception { URL yahoo = new URL("http://www.yahoo.com/"); URLConnection yc = yahoo.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } } 

Stack trace is same as Connection timed out. Why?

I suspect that might be problem with firewall but

  1. ping to google.com is okay
  2. it works in browser
  3. this approach fails for every URL I provide
  4. I use DJ WebBrowser component in other program and it works okay as a browser

How can I investigate more about this problem? Can I get to know which port numbers are going to be used when I run the code?

Thanks

Source Link
Nikolay Kuznetsov
  • 9.6k
  • 12
  • 61
  • 103

URLConnection.getInputStream() : Connection timed out

I use the code from Sun's java tutorial

import java.net.*; import java.io.*; public class URLConnectionReader { public static void main(String[] args) throws Exception { URL yahoo = new URL("http://www.yahoo.com/"); URLConnection yc = yahoo.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } } 

Stack trace is same as Connection timed out. Why?

I suspect that might be problem with firewall but

  1. ping to google.com is okay
  2. it works in browser
  3. this approach fails for every URL I provide
  4. I use DJ WebBrowser component in other program and it works okay as a browser

How can I investigate more about this problem? Can I get to know which port numbers are going to be used when I run the code?

Thanks