------

[ AD ] Port Monitor ( Try to use a Best WebSite Monitoring Tool )

------

 Hi all.

I develop an android application for Galaxy S that use UrlConnection for incomming stream connection.

Here is my my code:
public static InputStream getInputStream(String path) throws Exception {
            URL aURL = new URL(path);
            URLConnection conn = aURL.openConnection();            
            conn.connect();
            InputStream is = conn.getInputStream();
            return is;
}

That code worked properly during application session, but sometimes it generates exception
java.net.UnknownHostException: Host is unresolved: www.myserver.com:80
        at java.net.Socket.connect(Socket.java:1037)
        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:821)
        at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:807)
        at DownloadService.getInputStream(DownloadService.java:496)

I can repeat this bug on device and on emulator. 


PS
Here is another code that also throws those exception
public static InputStream getInputStream(String path) throws Exception {
            InputStream is = new URI(path).toURL().openStream();
            return is;
}

+ Recent posts