Unable to aquire image through ImageIO.read(url) because of connection timed out.
Posted
by Jake Frederix
on Stack Overflow
See other posts from Stack Overflow
or by Jake Frederix
Published on 2010-06-11T13:46:19Z
Indexed on
2010/06/11
13:53 UTC
Read the original article
Hit count: 382
Following code always fails
URL url = new URL("http://userserve-ak.last.fm/serve/126/8636005.jpg");
Image img = ImageIO.read(url);
System.out.println(img);
I've manually checked the url, and it is valid, and contains a valid jpg image. The problem I get is;
Exception in thread "main" javax.imageio.IIOException: Can't get input stream from URL! at javax.imageio.ImageIO.read(ImageIO.java:1385) at maestro.Main2.main(Main2.java:25) Caused by: java.net.ConnectException: Connection timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:310) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:176) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:163) at java.net.Socket.connect(Socket.java:546) at java.net.Socket.connect(Socket.java:495) at sun.net.NetworkClient.doConnect(NetworkClient.java:174) at sun.net.www.http.HttpClient.openServer(HttpClient.java:409) at sun.net.www.http.HttpClient.openServer(HttpClient.java:530) at sun.net.www.http.HttpClient.(HttpClient.java:240) at sun.net.www.http.HttpClient.New(HttpClient.java:321) at sun.net.www.http.HttpClient.New(HttpClient.java:338) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:814) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:755) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:680) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1005) at java.net.URL.openStream(URL.java:1029) at javax.imageio.ImageIO.read(ImageIO.java:1383) ... 1 more Java Result: 1
What does this mean? Funny thing is, if I change my internet-connection to that of the neighbour's wireless, it suddenly does work.
© Stack Overflow or respective owner